Mod-rewrite - Help me!!

Discussion in 'Programming' started by iBBnet, Jun 10, 2008.

  1. #1
    This one's confusing me, and I hope someone can clarify this for me.

    I'm trying to have all non-www pages in a subdirectory redirect to a www option.
    Everytime a non-www page is accessed in the browser, I want it to have a 301-redirect to the www. version:

    http://domain.com/subdirectory/pagenames.html   REDIRECT TO
    http://[B][U]www[/U][/B].domain.com/subdirectory/pagenames.html
    Code (markup):

    What's the htaccess code to incorporate?

    Thanks for the help guys!
     
    iBBnet, Jun 10, 2008 IP
  2. algaidaman

    algaidaman Active Member

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #2
    This should help you:

    
    # mod_rewrite in use
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{http_host} ^domain.com [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] 
    
    Code (markup):
     
    algaidaman, Jun 10, 2008 IP
  3. iBBnet

    iBBnet Peon

    Messages:
    902
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks! I'll give this a try and keep you posted...
     
    iBBnet, Jun 10, 2008 IP