El Patron Posted December 29, 2012 Share Posted December 29, 2012 Many users noticed that they are unable to customize their .htaccess using the back office as could be done in release 1.4.There has been some confusion on the board (me included) that if we customize the .htaccess and FTP to our shop that PrestaShop would overwrite it during .htaccess generation.This is not correct!PrestaShop will not overwrite the custom changes we make if we place the custom .htaccess definitions in the correct places.Example: Top of .htaccess Your custom code goes here # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again Example: Bottom of the .htaccess # ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again Your custom code Happy PrestaShopping 13 Link to comment Share on other sites More sharing options...
Site Posted December 29, 2012 Share Posted December 29, 2012 Great post @elpatron This should help many people out! 1 Link to comment Share on other sites More sharing options...
Bill Dalton Posted December 30, 2012 Share Posted December 30, 2012 You enable; Automatically redirect to Canonical URL But in small print Prestashop warns - Recommended, but your theme must be compliant My theme, (purchased from TM), is not compliant because if I try to access a product page with www, it doesn't "Automatically redirect to Canonical URL". So this tip is only necessary if your theme is not compatible with the redirect provided by Prestashop. Using the tip provided by elpatron, Put the following code above the reserve line, so that it will not be overwritten by Prestashop. Remember to change yoursite.com. RewriteEngine On RewriteCond %{HTTP_HOST} !^yoursite.com$ RewriteRule (.*) http://yoursite.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 Link to comment Share on other sites More sharing options...
josias Posted May 17, 2013 Share Posted May 17, 2013 You enable; Automatically redirect to Canonical URL But in small print Prestashop warns - Recommended, but your theme must be compliant My theme, (purchased from TM), is not compliant because if I try to access a product page with www, it doesn't "Automatically redirect to Canonical URL". So this tip is only necessary if your theme is not compatible with the redirect provided by Prestashop. Using the tip provided by elpatron, Put the following code above the reserve line, so that it will not be overwritten by Prestashop. Remember to change yoursite.com. RewriteEngine On RewriteCond %{HTTP_HOST} !^yoursite.com$ RewriteRule (.*) http://yoursite.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 Thank you for this TIP before it I had problems redirecting to www, and now is working properly. However Im a little afraid, because in the code appears twice RewriteEngine on. one above the comment and another one below. is safe doing this? by the way, I'm using the official theme of ps 1.5.4.1, why htacess redirecting is not working well? My only pending thing is the SEO words are not redirecting. I mean: /best-sales is not working, only is working the redirected friendly url /ventas. If I type /ventas I access, but If i type the original one (best-sales) I received 404 error Do you have idea how to solve? Thank you a lot! Please excuse me for my bad english Link to comment Share on other sites More sharing options...
mr-t Posted June 18, 2013 Share Posted June 18, 2013 Evening all, I am trying to resolve an SSL issue and this may be connected to what is being discussed here, can anyone offer any quidance? http://www.prestashop.com/forums/topic/255237-force-ssl-https-connection-for-all-pages/ Thank you. mr-t Link to comment Share on other sites More sharing options...
El Patron Posted June 18, 2013 Author Share Posted June 18, 2013 Evening all, I am trying to resolve an SSL issue and this may be connected to what is being discussed here, can anyone offer any quidance? http://www.prestasho...-for-all-pages/ Thank you. mr-t Hi mr-t, I suggest you open a new forum post deatiling what you are trying to accomplish. Link to comment Share on other sites More sharing options...
mr-t Posted June 19, 2013 Share Posted June 19, 2013 Hi mr-t, I suggest you open a new forum post deatiling what you are trying to accomplish. Hi Vincente, I have included the link to the new topic in my previous post. 1 Link to comment Share on other sites More sharing options...
Ketan Chaudhari Posted August 26, 2013 Share Posted August 26, 2013 Hi, Thanks, its awesome post. If i will add my custom code before or after main code ends and if .htaccess overwrite from out sources then our codes remains in file or it also overwrite??? waiting for your kind reply. Thanks... Link to comment Share on other sites More sharing options...
El Patron Posted August 26, 2013 Author Share Posted August 26, 2013 Hi, Thanks, its awesome post. If i will add my custom code before or after main code ends and if .htaccess overwrite from out sources then our codes remains in file or it also overwrite??? waiting for your kind reply. Thanks... as long as native PS is the updater of the .htaccess file then your custom changes will be preserved, assuming you put them in the correct place as noted above. 1 Link to comment Share on other sites More sharing options...
BoKr Posted September 3, 2013 Share Posted September 3, 2013 Well you can hardly imagine how often I had to manually change out httaccess since I had to tweak the php settings of our 'shared' host.... Thanks alot for this tipp. Some srutiny is always helpfull PS: Does it hartm even if we use a 'compatible' theme that is also customized by us? Link to comment Share on other sites More sharing options...
El Patron Posted September 7, 2013 Author Share Posted September 7, 2013 PS: Does it hartm even if we use a 'compatible' theme that is also customized by us? Hi B. sorry didn't see your question before now. It should make no difference. 1 Link to comment Share on other sites More sharing options...
CrossY Posted October 14, 2013 Share Posted October 14, 2013 I've tried editing my .htaccess after the last *end* comment thingy, but im gettin an Internal Server Error when I try to load the website after. It's a simple 301 redirect: //301 Redirect Old File Redirect 301 http://www.domain.com/nl/category/product1.html http://www.domain.com/product1.html I've tried to redirect 3 old pages this way (I don't have many products in my store). The old pages don't exist anymore, so i'd like them to redirect to the new page... Any suggestions? Link to comment Share on other sites More sharing options...
El Patron Posted October 23, 2013 Author Share Posted October 23, 2013 I've tried editing my .htaccess after the last *end* comment thingy, but im gettin an Internal Server Error when I try to load the website after. It's a simple 301 redirect: //301 Redirect Old File Redirect 301 http://www.domain.com/nl/category/product1.html http://www.domain.com/product1.html I've tried to redirect 3 old pages this way (I don't have many products in my store). The old pages don't exist anymore, so i'd like them to redirect to the new page... Any suggestions? here is an example...in 1.5, not sure when it was introduced but at the product level you can tell ps to redirect to t 404 or 301/302 to another product. redirectMatch 301 ^/link-to-your-product.html$ http://yourdomain/any-link 1 Link to comment Share on other sites More sharing options...
nish Posted January 28, 2014 Share Posted January 28, 2014 I have about 650 url from old shop which need to be redirected to new Prestashop path, if .htaccess file is added with that many urls. website will be slow down, any other suggestions ? or module Link to comment Share on other sites More sharing options...
El Patron Posted January 28, 2014 Author Share Posted January 28, 2014 I have about 650 url from old shop which need to be redirected to new Prestashop path, if .htaccess file is added with that many urls. website will be slow down, any other suggestions ? or module Hey nish, you can check with folks here: http://www.presto-changeo.com/ also you may want to search around a bit for some module and/or trick that will help you get this done. I would think the .htaccess is going to be the fastest because if module solution then it will have same if not more overhead...but I could be wrong. Link to comment Share on other sites More sharing options...
El Patron Posted February 15, 2014 Author Share Posted February 15, 2014 fyi if you are getting crawled by semalt dot com (they suck) put this in the top or bottom of your .htaccess file # block visitors referred from semalt.com RewriteEngine on RewriteCond %{HTTP_REFERER} semalt.com [NC] RewriteRule .* - [F] 1 Link to comment Share on other sites More sharing options...
indus Posted February 15, 2014 Share Posted February 15, 2014 (edited) fyi if you are getting crawled by semalt dot com (they suck) put this in the top or bottom of your .htaccess file # block visitors referred from semalt.com RewriteEngine on RewriteCond %{HTTP_REFERER} semalt.com [NC] RewriteRule .* - [F] Who are they? I have recently started noticing them in my backlinks a lot in awstats. But there are so many other .ru sites who also keep referring, i dont know if we can ever solve this issue. Edited February 15, 2014 by indus (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted February 15, 2014 Author Share Posted February 15, 2014 Who are they? I have recently started noticing them in my backlinks a lot in awstats. But there are so many other .ru sites who also keep referring, i dont know if we can ever solve this issue. don't really know who they are but they IMHO are bad bots. I added the above to my shop as they were doubling my visitors count (yesterday). It's best to always search outside of ps for this type of issue/resolution. 1 Link to comment Share on other sites More sharing options...
JDB Allyx Posted January 10, 2015 Share Posted January 10, 2015 Hello El Patron, Thanks for all your advices : they were a great help for me ! 1 Link to comment Share on other sites More sharing options...
garyjj127 Posted March 25, 2015 Share Posted March 25, 2015 Further to these issues, I have a strange problem regarding placing code outside the comments in .htaccess in PS 1.5.6.2. I have around 3000 redirects in my .htaccess file, and for some reason, Prestashop inserts it's code to the bottom of the file every time I update it. I've even tried editing the file and moving the redirects to the bottom of the page, but every time the htaccess is regenerated it changes it back. This means that I end up with all my redirects in the file before it gets to the prestashop bit, which really seems to slow performance of my site. Any ideas? Link to comment Share on other sites More sharing options...
koundou Posted May 21, 2015 Share Posted May 21, 2015 hi i transfer my prestashop with filezilla and databases . i receive this error Not FoundThe requested URL /en/ was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. when i try to upload the .htaccess file with these lines , the page is white and and not display the page, anyone can help please? # ~~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> <IfModule mod_env.c> SetEnv HTTP_MOD_REWRITE On </IfModule> RewriteEngine on #Domain: www.theiashop.com RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api$ api/ [L] RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] # Images RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L] # AlphaImageLoader for IE and fancybox RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L] # Dispatcher RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] </IfModule> AddType application/vnd.ms-fontobject .eot AddType font/ttf .ttf AddType font/otf .otf AddType application/x-font-woff .woff <IfModule mod_headers.c> <FilesMatch "\.(ttf|ttc|otf|eot|woff|svg)$"> Header add Access-Control-Allow-Origin "*" </FilesMatch> </IfModule> #If rewrite mod isn't enabled ErrorDocument 404 /index.php?controller=404 # ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again Link to comment Share on other sites More sharing options...
clubvapea Posted July 4, 2015 Share Posted July 4, 2015 Is it ok to have "RewriteEngine On" twice in the code? Once at the beginning in the custom code and once later in the original PS generated code?? Thanks You enable; Automatically redirect to Canonical URLBut in small print Prestashop warns - Recommended, but your theme must be compliantMy theme, (purchased from TM), is not compliant because if I try to access a product page with www, it doesn't "Automatically redirect to Canonical URL".So this tip is only necessary if your theme is not compatible with the redirect provided by Prestashop.Using the tip provided by elpatron,Put the following code above the reserve line, so that it will not be overwritten by Prestashop. Remember to change yoursite.com.RewriteEngine OnRewriteCond %{HTTP_HOST} !^yoursite.com$RewriteRule (.*) http://yoursite.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 Link to comment Share on other sites More sharing options...
garyjj127 Posted July 7, 2015 Share Posted July 7, 2015 Is it ok to have "RewriteEngine On" twice in the code? Once at the beginning in the custom code and once later in the original PS generated code?? Thanks I don't think it will cause a problem, as it just directs the RewriteEngine to be operating, so should be fine. Link to comment Share on other sites More sharing options...
Recommended Posts