Page 1 of 1

[SOLVED] 301 Redirect not working completely

Posted: Mon Apr 22, 2013 9:08 am
by Dutch_guy
A website has been published with a different domainname some time ago. Later on they decided to use a different domainname. Both domainnames point to the same server. The new domainname is an alias of the old one.

I'm now facing the problem that new url's are being shown with the old url.

I want to redirect everything from the old domain to the new domain with a 301 redirect.

My .htaccess looks like this:

Code: Select all

RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.peekwatersport\.nl$ [NC]
RewriteRule ^(.*)$ http://www.peekwatersport.nl/$1 [L,R=301]

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# but ignore POST requests.
#RewriteCond %{REQUEST_URI} !/$
#RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
#RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
I added the 2 lines after "RewriteBase /".

The redirect works, but the part after the domainname not completely.

For example this url:

http://www.ed-peek.nl/boten/44/71/maril ... ender.html

must become:

http://www.peekwatersport.nl/boten/44/7 ... ender.html

but becomes:

http://www.peekwatersport.nl/index.php/ ... ender.html

Anyone an idea how to solve this?

Re: 301 Redirect not working completely

Posted: Mon Apr 22, 2013 10:36 am
by velden
It just works. Don't know why you thinks it's not.

Re: 301 Redirect not working completely

Posted: Mon Apr 22, 2013 10:42 am
by Dutch_guy
Yes the redirect works, but the url's are not properly formed. Pretty url's don't work as expected.

Re: 301 Redirect not working completely

Posted: Mon Apr 22, 2013 11:55 am
by velden
I still stick to my assumption that it works.

When I click http://www.ed-peek.nl/boten/44/71/maril ... ender.html

I see http://www.peekwatersport.nl/boten/44/7 ... ender.html in my address bar.

Re: 301 Redirect not working completely

Posted: Mon Apr 22, 2013 12:15 pm
by Dutch_guy
Wow, I feel like a complete idiot, a moron and a fool. :o

It does indeed work, I tested on an other computer. I guess I was constantly calling a cached version on my own computer.

Thanks for the help!