glennlawre Posted January 11, 2013 Share Posted January 11, 2013 I have moved my store from another cart solution to Prestashop 1.5 and I am having issues with my old links not redirecting to my 404 "Page-not-found" page. The reason for this is I have had to set my store up without the www in the "Shop domain" in my BO. If I try to use www I cannot login to the BO and users cannot login to their accounts. I can see in my Google Webmaster account that there are a lot of pages that there were links to on my old site that don't exist on my new site. I know I should have redirects for these to relevant pages on the new site! But for now I would be happy if they redirected to my 404 "Page-not-found" page. Plus, I have tried to setup some redirects in .htaccess but they don't seem to work. The old links are trying to go to a www version of my pages, this is why they are not getting to my 404 page. However if I remove the www from the followed link, I do get the 404 page. E.g. here is a link to an old page that Google has found - http://www.honda50.i...n-set-did-chain It doesn't work, but if I remove the www it does work - http://honda50.ie/p/...n-set-did-chain Also, if I set www on my "Shop domain" in the BO the links then work fine, but this breaks logging into the BO and user accounts! I though .htaccess was supposed to redirect www pages to non-www pages when "Automatically redirect to Canonical URL" was enabled. I have also tried to manually create redirects in the .htaccess myself, but it does not work. The format I have used for the redirect is - RewriteRule ^/p/134/honda-50-chain-set-did-chain /page-not-found [R=301,L] Any help or advice would be great... Thanks in advance. Link to comment Share on other sites More sharing options...
El Patron Posted January 11, 2013 Share Posted January 11, 2013 (edited) see if this post helps: for non login-cart http://www.prestasho...47#entry1052147 for non www to www include in the top of your .htaccess RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] Edited January 11, 2013 by elpatron (see edit history) 2 Link to comment Share on other sites More sharing options...
glennlawre Posted January 11, 2013 Author Share Posted January 11, 2013 (edited) Thanks for the reply elpatron, I already had the same info in for SSL domain as Shop domain, but still give issue logging in. I have tried it with "Automatically redirect to Canonical URL" both disable and enabled. The only way I have found to fix this issue is to remove the www from the domain and have Automatically redirect to Canonical URL enabled. On the .htaccess, this did not work for me either. When I have www added to my domain, although it breaks logging in, the old links do work and redirect to my 404 page! Should I not have a redirect for www to non www? Or should this not get auto added when I select "Automatically redirect to Canonical URL"? Here is what is in my .htaccess by default when I enable SEF URLs <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^www.honda50.ie$ RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] I am actually getting a bit confused now as to what I should have configured and where... Cheers... Edited January 11, 2013 by glennlawre (see edit history) Link to comment Share on other sites More sharing options...
glennlawre Posted January 24, 2013 Author Share Posted January 24, 2013 Ok, I have half sorted this issue by adding the correct redirects in my .htaccess, I was using the wrong syntax! The rule I needed to use is - RewriteRule ^p/134/honda-50-chain-set-did-chain http://honda50.ie/5023-Honda-50-Chain-Set--DID-Chain-.html [R=301,L] This redirects page "http://www.honda50.ie/p/134/honda-50-chain-set-did-chain.aspx" to new page "http://honda50.ie/5023-Honda-50-Chain-Set-DID-Chain.html". The problem I had was I added a / before the old link, after "RewriteRule ^" it does not need this / and will not work with it. So - RewriteRule ^old link(just the bit after the domain.com/) new link [R=301,L] I also have to remove the www from my "Shop domain" in the BO and have the same in for SSL and enable "Automatically redirect to Canonical URL", if I don't do this I have issues logging into the BO and customer login. My redirects work fine now. However, old links that contain www in the address do not redirect correctly to my 404 page if I don't have a redirect set in my .htaccess for them. E.g. old link - http://www.honda50.ie/page-not-found?pagenumber=4 - does not go to the correct 404 page. However if I remove the www, http://honda50.ie/page-not-found?pagenumber=4 - it works fine. Can anyone advise why this is? Thanks in advance... Link to comment Share on other sites More sharing options...
hugosnel Posted April 22, 2013 Share Posted April 22, 2013 see if this post helps: for non login-cart http://www.prestasho...47#entry1052147 for non www to www include in the top of your .htaccess RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] This is part of the solution all referenced articleswill only direct to the homepage! Link to comment Share on other sites More sharing options...
El Patron Posted April 22, 2013 Share Posted April 22, 2013 This is part of the solution all referenced articleswill only direct to the homepage! No they won't.... Link to comment Share on other sites More sharing options...
varen Posted August 20, 2014 Share Posted August 20, 2014 for non www to wwwinclude in the top of your .htaccess RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] This solution worked for my prestashop 1.5.6.2. Thank you! it redirects all pages without www to correct pages with www. Didn't notice any problems with log in or order creation. 1 Link to comment Share on other sites More sharing options...
Recommended Posts