Dyniak Posted August 20, 2014 Share Posted August 20, 2014 (edited) Hi guys, I spend a lot of time to do (I guess) a simple thing in prestashop. I need to redirect an old link: http://domain.com/index.php?main_page=index&cPath=517 to: http://domain.com/20-aladdin i tried to do it myself in htaccess file but mb i'm doing something wrong... i'm placing also my htaccess file here: (without my redirect try) # ~~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_security.c>SecFilterEngine OffSecFilterScanPOST Off</IfModule><IfModule mod_rewrite.c>SetEnv HTTP_MOD_REWRITE OnRewriteEngine onRewriteCond %{HTTP_HOST} ^aga-dom.pl$RewriteRule . - [E=REWRITEBASE:/]RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]# ImagesRewriteCond %{HTTP_HOST} ^aga-dom.pl$RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]RewriteCond %{HTTP_HOST} ^aga-dom.pl$RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]RewriteCond %{HTTP_HOST} ^aga-dom.pl$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]RewriteCond %{HTTP_HOST} ^aga-dom.pl$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]RewriteCond %{HTTP_HOST} ^aga-dom.pl$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]RewriteCond %{HTTP_HOST} ^aga-dom.pl$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]RewriteCond %{HTTP_HOST} ^aga-dom.pl$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]RewriteCond %{HTTP_HOST} ^aga-dom.pl$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]RewriteCond %{HTTP_HOST} ^aga-dom.pl$RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]RewriteCond %{HTTP_HOST} ^aga-dom.pl$RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]# AlphaImageLoader for IE and fancyboxRewriteCond %{HTTP_HOST} ^aga-dom.pl$RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]# DispatcherRewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteCond %{HTTP_HOST} ^aga-dom.pl$RewriteRule ^.*$ - [NC,L]RewriteCond %{HTTP_HOST} ^aga-dom.pl$RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]</IfModule><IfModule mod_expires.c> 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"</IfModule>FileETag INode MTime Size<IfModule mod_deflate.c> <IfModule mod_filter.c> AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript </IfModule></IfModule>#If rewrite mod isn't enabledErrorDocument 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 againRewriteEngine OnRewriteBase /RewriteCond %{HTTP_HOST} !^aga-dom.pl [NC]RewriteRule ^(.*)$ http://aga-dom.pl%{REQUEST_URI} [R=301,L]# start ~ module watermark sectionOptions +FollowSymLinksRewriteEngine OnRewriteRule [0-9/]+/[0-9]+\.jpg$ - [F]# end ~ module watermark sectionzz It's not my shop and i'm not sure what someone exaclty did but i need that redirect so hard... Maybe can you also guys tell me where should i put my redirect code? Mb im doing this wrong? In my seo settings i got: - Friendly URL - YES - Automatically redirect to cannonical URL - YES Thak you very much for ur reply and help Edited August 20, 2014 by Dyniak (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted August 20, 2014 Share Posted August 20, 2014 what is the exact version of PrestaShop? Link to comment Share on other sites More sharing options...
Dyniak Posted August 20, 2014 Author Share Posted August 20, 2014 (edited) Sorry i didn't wrote that: PrestaShop 1.5.6.0 Edited August 20, 2014 by Dyniak (see edit history) 1 Link to comment Share on other sites More sharing options...
El Patron Posted August 20, 2014 Share Posted August 20, 2014 are the 'old' products still defined in shop but are disabled Link to comment Share on other sites More sharing options...
Dyniak Posted August 20, 2014 Author Share Posted August 20, 2014 (edited) Nope. Earlier it was other CMS (mb presta also) but here is a fresh installation of "new" Presta and database. I need to redirect those old links to the new site categories cause they are in google and direct to 404 error. The history of this site is much worse. My friend (his site) ordered a new version of old shop. They made it but the rly didn't care about seo. They didnt make any redirections before. So the result of site is that GWT says that there i over 70000 link which shows 404 error. I wanna try help him and redirect some other categories (not the whole shop with product but only categories) to the right place by redirection. Edited August 20, 2014 by Dyniak (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted August 20, 2014 Share Posted August 20, 2014 i think this post will help you http://www.prestashop.com/forums/topic/301400-solved-how-to-redirect-products-page-to-categorys-page/?p=1540905 Link to comment Share on other sites More sharing options...
Dyniak Posted August 20, 2014 Author Share Posted August 20, 2014 I tried to put that code here: <IfModule mod_rewrite.c>SetEnv HTTP_MOD_REWRITE OnRewriteEngine onRewriteCond %{HTTP_HOST} ^aga-dom.pl$RewriteRule ^(.*)index.php?main_page=index&cPath=517$ http://aga-dom.pl/20-aladdin$1 [R=301,L,NC]RewriteRule . - [E=REWRITEBASE:/]RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] But it still wont work... Am I stupid or what? Tried also some other combination but with the same result. Link to comment Share on other sites More sharing options...
garyjj127 Posted November 27, 2014 Share Posted November 27, 2014 I have a strange problem with 1.5.6.2. I put all my redirects directly under the line in htaccess that reads: # ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again However, if I change any of the performance settings it completely wipes the 301 Redirects off. Luckily I had a backup. Any idea why this is happening? Link to comment Share on other sites More sharing options...
El Patron Posted November 27, 2014 Share Posted November 27, 2014 see if this helps http://www.prestashop.com/forums/topic/2131[spam-filter]tip-15-16-and-custom-htaccess/ Link to comment Share on other sites More sharing options...
garyjj127 Posted November 27, 2014 Share Posted November 27, 2014 Thanks for your reply El Patron! I have placed my 301's outside the comments as specified, but they still get deleted! It's no big deal as I can back the up before making any back end performance changes, but it's just a bit of a pain. I have 5000 301's (yes, 5000). Having said that, they don't seem to slow the site down! Luckily I have a very good service provider Link to comment Share on other sites More sharing options...
El Patron Posted November 27, 2014 Share Posted November 27, 2014 Thanks for your reply El Patron! I have placed my 301's outside the comments as specified, but they still get deleted! It's no big deal as I can back the up before making any back end performance changes, but it's just a bit of a pain. I have 5000 301's (yes, 5000). Having said that, they don't seem to slow the site down! Luckily I have a very good service provider I have never seen this issue and has been supported by PrestaShop since at least 1.4, what is your exact PrestaShop version. Link to comment Share on other sites More sharing options...
garyjj127 Posted November 27, 2014 Share Posted November 27, 2014 It's 1.5.6.1. It's really strange. I'll try putting something before the start tag and see what happens! Link to comment Share on other sites More sharing options...
garyjj127 Posted November 27, 2014 Share Posted November 27, 2014 OK, I tried it above the start comment and it still gets deleted! Here's the original code (without my 301's). # ~~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 RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] # Images RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ 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] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ 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] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ 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] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ 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] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ 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] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ 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] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L] # AlphaImageLoader for IE and fancybox RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ 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 RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ RewriteRule ^.*$ - [NC,L] RewriteCond %{HTTP_HOST} ^www.jamesandjames.com$ RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] </IfModule> <IfModule mod_expires.c> 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" </IfModule> FileETag INode MTime Size <IfModule mod_deflate.c> <IfModule mod_filter.c> AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript </IfModule> </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...
El Patron Posted November 28, 2014 Share Posted November 28, 2014 ps version? I will test it out...as I am curious to see if not working on this version of ps... I use my .htaccess module (back office .htaccess editor) on 1609 and have no issue, it works from ps standpoint like you hand modified the .htaccess and if I regenerate .htaccess by change setting in back office I don't have issue... Link to comment Share on other sites More sharing options...
garyjj127 Posted November 28, 2014 Share Posted November 28, 2014 Version is 1.5.6.1 Link to comment Share on other sites More sharing options...
garyjj127 Posted November 28, 2014 Share Posted November 28, 2014 Ah. I wonder if that's the problem. I download the file to my PC. Add the redirects and then upload it. I didn't realise you could edit directly in PS Link to comment Share on other sites More sharing options...
Recommended Posts