Mobile app version of vmapp.org
Login or Join
Gloria169

: Htaccess/cPanel 301 redirects not working for add-on domain I've already looked at many samples and tutorials how to set up those 301 redirects on Apache and can't figure out why some are not

@Gloria169

Posted in: #301Redirect #Cpanel #Htaccess

I've already looked at many samples and tutorials how to set up those 301 redirects on Apache and can't figure out why some are not working. 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. But it "works" if you type in a page which does not exist on the old domain. The same is true for directories which do not exist on the old domain. So whenever you type a non-existing URL (page or folder) the redirections is taking place (but of course produces 404 errors of on the new domain).

In addition it also works for the domain name itself. So just typing "old.com" correctly redirects to "new.com".

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/" [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.

EDIT 3: This is the .htaccess of the top-level domain:

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName toplvl.com AuthUserFile /home2/a_user/public_html/_vti_pvt/service.pwd
AuthGroupFile /home2/a_user/public_html/_vti_pvt/service.grp

RewriteCond %{HTTP_HOST} ^toplvl.com [OR]
RewriteCond %{HTTP_HOST} ^www.toplvl.com
RewriteRule ^(.*)$ www.toplvl.com/ [L,R=301,NC]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gloria169

1 Comments

Sorted by latest first Latest Oldest Best

 

@Hamaas447

I guess you should not enclose your new.com with quotes "", neither scape it because your regular expression is inside RewriteCond, not inside the target.

Try something like this:

Options +FollowSymlinks
RewriteEngine on


RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule ^some-page.php$ www.new.com/some-other-page.php [R=301,L]
RewriteRule ^(.*)$ www.new.com/ [R=301,L]


Edit: I've added specific url redirection.

As you can see, order matters, is you have something specific you should place it upfront other rules that are more generic like host redirection.

If you need to play a little bit with htaccess you should use a tester like this.
You have to enter urls like www.old.com/somepage.php, or www.old.com, always using .

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme