We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    I'm building a new website and would like to keep the SEO results by redirecting the old URLs to the new pages.

    When I add this in my htaccess:
    Redirect 301 /page.php?p=home&l=nl http://www.my-site.nl/

    Then navigate to: http://www.my-site.nl/page.php?p=home&l=nl (which doesn't exists) I should be redirected to the homepage but I see the 404 page / page not found I have set in the manager.


    My full htaccess file:
    AddDefaultCharset utf-8
    
    Redirect 301 /page.php?p=home&l=nl http://www.sub.mysite.nl/
    Redirect 301 /page.php?p=bedrijf&l=nl http://www.sub.mysite.nl/bedrijf
    Redirect 301 /page.php?p=activiteiten&l=nl http://www.sub.mysite.nl/activiteiten
    Redirect 301 /page.php?p=contact&l=nl http://www.sub.mysite.nl/contact
    Redirect 301 /page.php?p=vacatures&l=nl http://www.sub.mysite.nl/vacatures
    ... some more...
    
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
    RewriteRule .* - [F,L]
    
    # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
    RewriteCond %{HTTP_HOST} !^$
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{HTTP_HOST} (.+)$
    RewriteRule ^(.*)$ http://www.%1/$1 [R=permanent,L] . 
    
    
    RewriteRule ^(manager|assets)/.*$ - [L]
    RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    



    This doesn't work either:
    RewriteRule ^page.php?p=bedrijf&l=nl http://www.sub.mysite.nl/bedrijf [L,NE,R=301]



    This question has been answered by fourroses666. See the first response.

    [ed. note: fourroses666 last edited this post 12 years, 5 months ago.]
      Evolution user, I like the back-end speed and simplicity smiley
      • 9995
      • 1,613 Posts
      Seems it has to do with the ?p=home&l=nl

      This works:
      Redirect 301 /page.php http://www.sub.mysite.nl/

      This doesn't:
      Redirect 301 /page.php?blabla http://www.sub.mysite.nl/

      Any workarround possible someone knows of?
        Evolution user, I like the back-end speed and simplicity smiley
      • discuss.answer
        • 9995
        • 1,613 Posts
        The solution:

        RewriteCond %{QUERY_STRING}  ^p=home&l=nl$ [NC]
        RewriteRule ^page\.php$ http://www.sub.mysite.nl/home? [R=301,NE,NC,L]
        


        Now when I go to mysite.nl/page.php?p=home&l=nl I get redirected to mysite.nl/home
          Evolution user, I like the back-end speed and simplicity smiley