Wesley Wesley - 25 days ago 19
Apache Configuration Question

Htaccess multiple redirects not working

We have a new domain name and want to redirect our old customers.
Now we have a small change we are changing from a nl domain to com, so we want our nl customers to go to the .com/nl and the English customers from /us/ to .com
It needs to be a 301 redirect and send the URL.
So we got this now, but it's not working

RewriteEngine on
RewriteRule ^olddomain\.nl/ca$ /newdomain.com/ca/? [L,R=301]
RewriteRule ^ olddomain\.nl/dk$ /newdomain.com/dk/? [L,R=301]
RewriteRule ^ olddomain\.nl/us$ /newdomain.com/? [L,R=301]
RewriteRule ^ olddomain\.nl$ /newdomain.com/nl? [L,R=301]


Wat are we doing wrong I'm in panic because we need to go live tomorrow. Hope somebody can help me

Ok so we got a bit furter.

RewriteEngine on
#olddomain/us =>newdomain/
RewriteRule ^us/?$ http://newdomain.com/ [NE,L,R]
#olddomain.nl/ =>newdomain/nl
RewriteRule ^$ http://newdomain.com/nl/ [NE,L,R]
#olddomain/others =>newdomain/others
RewriteRule ^(ca|dk)/ http://newdomain.com/$1 [NE,L,R=301]


Not working


  1. olddomain.nl to newdomain.com/nl/

  2. sending the old URL to the new pagina like keep
    olddomain.nl/oldpage.php


Answer

You can use the following rule in olddomain/.htaccess :

RewriteEngine on
#1)olddomain/us =>newdomain/
RewriteRule ^us/?(.*)?$ http://newdomain.com/$1 [NE,L,R]
#2)olddomain/others =>newdomain/others
RewriteRule ^(ca|dk)(/.*)?$ http://newdomain.com/$1$2 [NE,L,R=301]
#3)olddomain.nl/page =>newdomain/nl/page
RewriteRule ^(.*)$ http://newdomain.com/nl/$1 [NE,L,R]
Comments