SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    htaccess rewrite question

    Hi Guys,

    I want to use htaccess to rewrite the url using the following rules:

    - Domain name: mydomain.com
    - Rewrite should only occur when this is typed into the browser:
    http://mydomain.com
    OR
    http://www.mydomain.com
    - Rewrite will not occur on additional requests like:
    http://www.mydomain.com/index.php

    Can this be done?

  2. #2
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    London
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I'm unsure if this is what you want but:

    # force all urls to www.
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^(.*)\.mydomain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

    This will force all urls to be http://www.mydomain.com and not http://mydomain.com

    That would need to be in your document_root .htaccess


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •