Jump to content

URL problem in new prestashop 1.4.1 with htaccess


kkshop

Recommended Posts

Hi guys,
in older version of prestashop we used this code added to prestashop generated htaccess:

RewriteCond %{HTTP_HOST} !^www\.something\.com
RewriteRule ^(.*)$ http://www.something.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html)\ HTTP
RewriteRule ^(.*)index\.(php|html)$ /$1 [R=301,L]



but new prestashop generated strange version of htaccess and I cant edit it , We need our site will appear always as www.something.com not something.com, what does new prestashop


How to edit this?
Code from new prestashop:

# URL rewriting module activation
RewriteEngine on

# URL rewriting rules
RewriteRule ^api/?(.*)$ /webservice/dispatcher.php?url=$1 [QSA,L]
RewriteRule ^([a-z0-9]+)\-([a-z0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2$3.jpg [L]
RewriteRule ^([0-9]+)\-([0-9]+)/[_a-zA-Z0-9-]*\.jpg$ /img/p/$1-$2.jpg [L]
RewriteRule ^([0-9]+)(\-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*\.jpg$ /img/c/$1$2.jpg [L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]* /category.php?id_category=$1 [QSA,L]
RewriteRule ^[a-zA-Z0-9-]*/([0-9]+)\-[a-zA-Z0-9-]*\.html /product.php?id_product=$1 [QSA,L]
RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*) /supplier.php?id_supplier=$1 [QSA,L]
RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*) /manufacturer.php?id_manufacturer=$1 [QSA,L]
RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms=$1 [QSA,L]
RewriteRule ^content/category/([0-9]+)\-([a-zA-Z0-9-]*) /cms.php?id_cms_category=$1 [QSA,L]
RewriteRule ^page-not-found$ /404.php [QSA,L]
RewriteRule ^address$ /address.php [QSA,L]
RewriteRule ^addresses$ /addresses.php [QSA,L]
RewriteRule ^authentication$ /authentication.php [QSA,L]
RewriteRule ^best-sales$ /best-sales.php [QSA,L]
RewriteRule ^cart$ /cart.php [QSA,L]
RewriteRule ^contact-us$ /contact-form.php [QSA,L]
RewriteRule ^discount$ /discount.php [QSA,L]
RewriteRule ^guest-tracking$ /guest-tracking.php [QSA,L]
RewriteRule ^order-history$ /history.php [QSA,L]
RewriteRule ^identity$ /identity.php [QSA,L]
RewriteRule ^manufacturers$ /manufacturer.php [QSA,L]
RewriteRule ^my-account$ /my-account.php [QSA,L]
RewriteRule ^new-products$ /new-products.php [QSA,L]
RewriteRule ^order$ /order.php [QSA,L]
RewriteRule ^order-follow$ /order-follow.php [QSA,L]
RewriteRule ^quick-order$ /order-opc.php [QSA,L]
RewriteRule ^order-slip$ /order-slip.php [QSA,L]
RewriteRule ^password-recovery$ /password.php [QSA,L]
RewriteRule ^prices-drop$ /prices-drop.php [QSA,L]
RewriteRule ^search$ /search.php [QSA,L]
RewriteRule ^sitemap$ /sitemap.php [QSA,L]
RewriteRule ^stores$ /stores.php [QSA,L]
RewriteRule ^supplier$ /supplier.php [QSA,L]


# Catch 404 errors
ErrorDocument 404 /404.php


   ExpiresActive On
   ExpiresByType image/gif "access plus 1 month"
   ExpiresByType image/jpeg "access plus 1 month"
   ExpiresByType image/png "access plus 1 month"
   ExpiresByType text/css "access plus 1 week"
   ExpiresByType text/javascript "access plus 1 week"
   ExpiresByType application/javascript "access plus 1 week"
   ExpiresByType application/x-javascript "access plus 1 week"
   ExpiresByType image/x-icon "access plus 1 year"


FileETag INode MTime Size

   AddOutputFilterByType DEFLATE text/html
   AddOutputFilterByType DEFLATE text/css
   AddOutputFilterByType DEFLATE text/javascript
   AddOutputFilterByType DEFLATE application/javascript
   AddOutputFilterByType DEFLATE application/x-javascript

Link to comment
Share on other sites

cannonical redirect is now part of prestashop 1.4 . in BO / preferences / SEO & Urls make sure that Shop domain name is filled in www.something.com (without the http) and Automatically redirect to Canonical url is set to yes. this should then do an automatic redirect for you.

If that does not work here is the old fashioned way of doing it with .htaccess

# if no subdomain redirect to www
# RewriteCond %{HTTP_HOST} ^something.com$ [NC]
# RewriteRule ^(.*)$ http://www.something.com/$1 [R=301,L]



just reading the code you posted at the top. you do not need to escape the dots, i am not sure what the last 2 lines acheive. The other important thing is at which point you place this code. I would place it at the very top before all other rules.

Link to comment
Share on other sites

  • 2 weeks later...

Another problem. When I set there adress with WWW., it runs OK.
BUT ORDER CANT BE DONE. In order process there are URLS without WWW and you cant go to next step after sellecting shipping method.

It is bug? How to fix it please?

Thank you

Link to comment
Share on other sites

Actually, you do not need to edit .htaccess


Back Office-> Preferences->SEO & URLs
URLs Setup:
change your "Shop domain name" and "Shop domain name for SSL" to www.yourdomain.com

So easy,that's ok

Link to comment
Share on other sites

Actually, you do not need to edit .htaccess


Back Office-> Preferences->SEO & URLs
URLs Setup:
change your "Shop domain name" and "Shop domain name for SSL" to www.yourdomain.com

So easy,that's ok


Very nice mengp... Thats WORK !!
Thanks... :)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...