PrestaShop: non-www URLs redirecting to 404 error page

Debiprasad picture Debiprasad · Nov 26, 2013 · Viewed 8.3k times · Source

I am experiencing a weird issue on my PrestaShop website.

When I am opening an URL without WWW on it, it redirects to the WWW page, but displays 404 page.

for example, when I am trying to access http://mydomain.com/home/contact-us it takes me to http://www.mydomain.com/home/contact-us?controller=404. It should not add ?controller=404 to the end of the url. Why it's doing this and how to fix this issue?

Answer

Jnanaranjan picture Jnanaranjan · Nov 27, 2013

You need to manually edit the .htaccess file of your Prestashop website. You can redirect all non-www urls to add www using this code.

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

Place the code on top of your .htaccess file or within the condition block for checking mod_rewrite