htaccess/cPanel 301 redirects not working for add-on domain

Posted by Clemens on Pro Webmasters See other posts from Pro Webmasters or by Clemens
Published on 2014-06-13T11:44:45Z Indexed on 2014/06/13 15:43 UTC
Read the original article Hit count: 635

Filed under:
|
|

I've already looked at many samples and tutorials how to set up those 301 redirects on Apache and can't figure out why only the second one is working:

Options +FollowSymlinks
RewriteEngine on

#doesn't work:
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule ^page-still-exists.htm$ "http://www.new.com/new-target-page.htm" [R=301,L]

#works:
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule ^page-does-no-longer-exist.htm$ "http://www.new.com/" [R=301,L]

#works:
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule ^folder/otherpage.htm$ "http://www.new.com/" [R=301,L]

#works:
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule ^/?$ "http://www.new.com/" [R=301,L]

#doesn't work:
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule ^somepage.htm$ "http://www.old.com/some-page.htm" [R=301,L]

I have no idea why only the second one is working. The only difference I can see is, that in the second case the old page does no longer exist on the old domain. But whenever I want to redirect any still existing page from the old domain to the new domain the page on the old domain is still used.

Any input is much appreciated because this is slowly driving me crazy :)

EDIT: I added the complete htaccess file.

EDIT 2: So I removed almost all redirects and currently my htaccess looks like this:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^old\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old\.com$
RewriteRule ^(.*)$ "http\:\/\/www\.new\.com\/$1" [R=301,L]

The only redirect that is working is the simple one from old.com to new.com. A redirect like old.com/page.htm to new.com or even new.com/page.htm is not working. And actually I really don't know where this redirect is actually coming from... Can a 301 really be so complicated?

© Pro Webmasters or respective owner

Related posts about htaccess

Related posts about 301-redirect