I have an odd scenario that I cannot figure out. When Auto-redirect to Base URL is set to 301 or 302, the homepage of my website redirects correctly to what I have defined as my base URL (I am using non-www as my base). However, when this is on and I try to visit one of my subpages using the www. version, it sends me back to my homepage. IE: www.example.com redirects correctly to example.com www.example.com/subpage, also sends me to example.com - not the correct subpage.

I thought that I may be able to circumvent this by disabling the base URL redirect and then manually modifying my .htaccess file. I used the following code:

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^example\.com$ [NC] 
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

In this case it is a similar situation... when visiting www.example.com I am correctly redirected to example.com. However, when I visit www.example.com/subpageI am incorrectly redirected to example.com/index.php

I found a few variations of the redirect code and all had the same results.

I then tried to manually redirect individual pages, also to no avail.

I also tried setting a manual redirect through the Magento URL Rewrites in the dashboard.

Nothing seems to work and I am out of ideas. Any help or guidance is appreciated.

1 Answer 1


Issue has been resolved. This thread was recommended to me by the system after posting my message: Redirect 'non www prefix to 'www' prefix still not working after disabling 'Auto-redirect to Base URL'

I disabled base url redirects and then moved the code to the beginning of .htaccess and this did the trick.

Thank you for having a very reliable and accurate 'related posts' feature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.