[Mod Rewite Help Needed] Redirect all urls to www.domain.com

Discussion in 'Apache' started by agnivo007, Oct 21, 2007.

  1. #1
    I want all urls (whether httpd or www) to be redirected to http://www.domain.com

    http://domain.com
    http://domain.com/a.php
    http://domain.com/abc/
    http://domain.com/abc
    http://www.domain.com/a.php
    http://www.domain.com/abc/
    http://www.domain.com/abc

    All redirected to http://www.domain.com
     
    agnivo007, Oct 21, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Delete everything

    ErrorDocument 404 /
     
    Nintendo, Oct 22, 2007 IP
  3. nwilkens

    nwilkens Member

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    Consider adding an entry in your httpd.conf or .htaccess using mod_rewrite..

    below is an example I have used in the past..

    RewriteCond %{http_host} ^mnxsolutions.com
    RewriteRule ^(.*) http://www.mnxsolutions.com/$1 [R=301,L]


    The first line, RewriteCond says .. if http host starts with "mnxsolutions.com" ( the ^ indicates start of line otherwise the expression could match other forms, like sdfdmnxsolutions.com ).

    The second lines then rewrites the URL to www... with a 301 redirect..

    Its a start, but reference http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html for additional detail.
     
    nwilkens, Oct 22, 2007 IP
  4. agnivo007

    agnivo007 Peon

    Messages:
    4,290
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well, I really didn't want to use the ErrorDocument thing...but I figured it out already.

    Thanks, I'll check the other suggestion too (but it looks familiar; a http to www redirect).
     
    agnivo007, Oct 22, 2007 IP