Andrew H Posted August 5, 2013 Share Posted August 5, 2013 (edited) I recently ugraded to 1.5. Mostly everything's ok now except some of the old pages are indexed in search engines as: domainname.com and some as: www.domainname.com If you type domainname.com into the web browser (even with canonical URL on) it just redirects here to the 404 page: www.domainname.com?controller=404 but I just want it to redirect to www.domainname.com How do I get around this problem and is this normal behaviour in 1.5? Ideal situation is anyone who enters a domain without www. automatically gets taken to the correct web address. I'm guessing this is a htaccess edit? Can someone help me on this as I'm concerned any edit here will be over-written automatically by PS? thanks Edited August 5, 2013 by Andrew H (see edit history) Link to comment Share on other sites More sharing options...
swsindonesia Posted August 5, 2013 Share Posted August 5, 2013 Hi, 1) make sure your Apache enables mod_rewrite 2) make sure your url configuration in PS back-office admin is properly configured to www.domainname.com 3) If your DNS record is already properly configured by using CNAME domainname.com for www.domainname.com, there shouldn't be any problem 4) You can try to add this 301 redirection to your .htaccess file, just add after the RewriteEngine On RewriteEngine On RewriteCond %{HTTP_HOST} ^domainname.com$ RewriteRule (.*)$ http://www.domainname.com/$1 [R=301,L] best of luck! 1 Link to comment Share on other sites More sharing options...
Andrew H Posted August 5, 2013 Author Share Posted August 5, 2013 (edited) Great, thanks for you advice. The back office is configured correctly as www.domainname.com There's already some code similar to above and I'm not sure if I should simply add what you've suggested or replace -as I don't want prestashop to over-write it again. This is what I have at the top of my .htaccess right now... It looks like I can add something that won't be over-written at the top (but not sure what to do about the similar exisitng reference to the webaddress at the top)... # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution # http://www.prestashop.com - http://www.prestashop.com/forums <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^www.domainname.com$ RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] if I type http:// domainname.com then I get a 404 error but if I type in domainname.com it does forward to http:// www.domainname.com (spaces added just to stop the web address turning into a link) Edited August 5, 2013 by Andrew H (see edit history) Link to comment Share on other sites More sharing options...
Andrew H Posted August 5, 2013 Author Share Posted August 5, 2013 (edited) I updated the code as below which I'd initially thought fixed the problem (it fixes the redirect problem) but causes the website to slow to a crawl. If someone can help advise how to get around this problem so I don't have slow website issues, much appreciated. RewriteEngine On RewriteCond %{HTTP_HOST} ^domainname.com$ RewriteRule (.*)$ http://www.domainname.com/$1 [R=301,L] # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution # http://www.prestashop.com - http://www.prestashop.com/forums<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^www.domainname.com$ RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] Edited August 5, 2013 by Andrew H (see edit history) Link to comment Share on other sites More sharing options...
swsindonesia Posted August 7, 2013 Share Posted August 7, 2013 Hi Andrew, What exactly do you mean with "slow to a crawl" ? PS only writes the .htaccess when you enable Friendly URL and other Apache options from the back-end, after that it won't touch the .htaccess anymore. At this point you can add your redirection rule after the RewriteEngine On, so you won't have two of them within the same .htaccess Link to comment Share on other sites More sharing options...
Andrew H Posted August 9, 2013 Author Share Posted August 9, 2013 just to update, this problem wasn't caused by htaccess, it was caused by datamining and/or database.... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now