Rewrite 301 Problem

Discussion in 'Site & Server Administration' started by SEOdir.net, Jun 7, 2008.

  1. #1
    Hello, I have that in my htaccess:

    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^mysite.tld
    RewriteRule (.*) http://www.mysite.tld/$1 [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^mysite.tld/forum
    RewriteRule (.*) http://www.mysite.tld/forum/$1 [R=301,L]
    Code (markup):
    The first is working find but when I go to mysite.tld/forum it redirects me to www.mysite.tld, where is the fault ?

    Thanks
     
    SEOdir.net, Jun 7, 2008 IP
  2. relixx

    relixx Active Member

    Messages:
    946
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    70
    #2
    What do the headers say?
     
    relixx, Jun 15, 2008 IP
  3. SEOdir.net

    SEOdir.net Banned

    Messages:
    2,549
    Likes Received:
    105
    Best Answers:
    0
    Trophy Points:
    173
    #3
    I want to do thta:

    when I go to mysite.tld/directory then I want to be redirected to www.mysite.tld/directory
     
    SEOdir.net, Jun 15, 2008 IP
  4. relixx

    relixx Active Member

    Messages:
    946
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    70
    #4
    Try putting this line first:

    RewriteCond %{HTTP_HOST} ^mysite.tld/forum
    RewriteRule (.*) http://www.mysite.tld/forum/$1 [R=301,L]
    The "L" in [R=301,L] means that that rule is the last one that'll be done on the URL that meets the condition.
     
    relixx, Jun 15, 2008 IP
    Technique likes this.