ecommdev Posted December 12, 2014 Share Posted December 12, 2014 Prestashop 1.6.0.9 Multistore. Currently have multiple stores enabled within prestashop, each with their own domain. Stores migrated from different shopping cart system into prestashop system. I have all urls used in previous system and would like to setup 301 redirects to each category and product page so Google and others will update their index and ensure no links are lost. I understand this can be done via the .htaccess file, however when I reviewed it looked more complicated than usual since rewrite for .php and others are activated. I tried to include a few 301 redirects within the .htaccess file however, after upload the entire site was internal server error 500. I did something wrong. 1) Is there a simple formula to follow (old url) to new urls within the prestashop .htaccess file? 2) Is there a module for prestashop that can handle previous system urls and redirect to certain categories & products within prestashop? I look forward to anyone providing guidance. Thanks. Link to comment Share on other sites More sharing options...
ecommdev Posted December 15, 2014 Author Share Posted December 15, 2014 insight from anyone? Link to comment Share on other sites More sharing options...
kyrios Posted December 15, 2014 Share Posted December 15, 2014 1. yes, it can be done. Put your rewrite cond below this code # ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again RedirectMatch 301 old_url1 new_url1 RedirectMatch 301 old_url2 new_url2 RedirectMatch 301 old_url3 new_url3 and so on. 2. I do not think that kind of module is exist, but it can be done easily(?) in .htaccess as well. Problem is looks like you have to hire someone to do the job, or read and read and read the rewrite code for apache. I have similar problem like yours, but no1 was helping me (from this forum). But finally I was (partially) helped by someone else from different forum. To start, study this link. 1 Link to comment Share on other sites More sharing options...
lanski Posted December 16, 2014 Share Posted December 16, 2014 i think RedirectPermanent is better Link to comment Share on other sites More sharing options...
Paul_PL Posted December 17, 2014 Share Posted December 17, 2014 Hello, I have the same problem, RedirectMatch 301 old_url1 new_url1 Doesn't work, it do nothing because prestashop have 2 rules RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] Which redirect everything to index.php and later url is rewritten by PHP. If anyone have idea how to solve this problem please write us. Link to comment Share on other sites More sharing options...
ecommdev Posted December 19, 2014 Author Share Posted December 19, 2014 Still hoping someone can provide greater insight into this issue. What are merchants doing when they are migrating from a different shopping cart system, losing all their url links OR what? No one has thought up and developed a module to provide a solution to this problem? Feedback please. Link to comment Share on other sites More sharing options...
Paul_PL Posted December 19, 2014 Share Posted December 19, 2014 Since almost every link is rewriten by php and .htaccess redirect every link by index.php it can be done using php insted of htaccess. Create new file called old_site_redirect.php and pase code below (change old_url and new url to real path $url_redir_maps = array( '/some_old_url.html' => '/some_new_url', '/old_url2' => '/new_url2', (...and so on) ); if(in_array(@$_SERVER['REQUEST_URI'], array_keys($url_redir_maps))){ header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$url_redir_maps[@$_SERVER['REQUEST_URI']]); exit; } Now in prestashop index.php include this file on top of this file so it looks like this: require_once('old_site_redirect.php'); require(dirname(__FILE__).'/config/config.inc.php'); Dispatcher::getInstance()->dispatch(); I've checked on PS 1.6 and works great. Hope this help someone 5 Link to comment Share on other sites More sharing options...
ecommdev Posted December 27, 2014 Author Share Posted December 27, 2014 Since almost every link is rewriten by php and .htaccess redirect every link by index.php it can be done using php insted of htaccess. Create new file called old_site_redirect.php and pase code below (change old_url and new url to real path $url_redir_maps = array( '/some_old_url.html' => '/some_new_url', '/old_url2' => '/new_url2', (...and so on) ); if(in_array(@$_SERVER['REQUEST_URI'], array_keys($url_redir_maps))){ header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$url_redir_maps[@$_SERVER['REQUEST_URI']]); exit; } Now in prestashop index.php include this file on top of this file so it looks like this: require_once('old_site_redirect.php'); require(dirname(__FILE__).'/config/config.inc.php'); Dispatcher::getInstance()->dispatch(); I've checked on PS 1.6 and works great. Hope this help someone I created a old_site_redirect.php included the coding you provided with the old and new urls. and modified the index.php file. It isn't working. Its not redirecting and its showing the coding in the header of all pages on the website. I am glad a tested on the sandbox site. anyway, perhaps the coding doesn't work with 1.6.0.9 WITH Multistore enabled. Overall, still looking for input. Help requested. Link to comment Share on other sites More sharing options...
Whiley Posted December 27, 2014 Share Posted December 27, 2014 It isn't working. Its not redirecting and its showing the coding in the header of all pages on the website. Try it again but with this little tag at the top of your php-page: <?php regards Whiley 1 Link to comment Share on other sites More sharing options...
ecommdev Posted December 28, 2014 Author Share Posted December 28, 2014 Try it again but with this little tag at the top of your php-page: <?php regards Whiley That fixed the issue and now the 301 redirects are working. Thank you. Now, I have a follow up question. Since in the php command I can't include the domains, what should be done when two different sites have the same url extension (using multistore setup)? Example in the same industry. OLD domain.com/old-site-url.html > NEW /category/demo-product.html OLD domain2.com/old-topic-url.htm > NEW /category/demo-product.html You will notice the new destination has two different domains BUT the url structure is entirely the same. (/category/demo-product.html). What should be done since I can't include the domain in the 301 redirect php command? Let me know. Link to comment Share on other sites More sharing options...
Paulo Ens Posted March 30, 2015 Share Posted March 30, 2015 We did it and it works, but when the shopping cart has ajax enabled it returns an error and doesn't work to add a product to the cart. Take a look on the error: --- Impossible to add the product to the cart. textStatus: 'parsererror' errorThrown: 'SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data' responseText: {"products":[{"id":23599,"link":"http:\/\/www.pares.com.br\/loja\/fluke\/instrumentos-de-bancada-e-portateis\/multimetros\/23599-multimetro-industrial-flk-87-5.html","quantity":1,"image":"https:\/\/www.pares.com.br\/loja\/1267-home_default\/multimetro-industrial-flk-87-5.jpg","image_cart":"https:\/\/www.pares.com.br\/loja\/1267-cart_default\/multimetro-industrial-flk-87-5.jpg","priceByLine":"R$3.070,00","name":"MULTIMETRO INDUSTRIAL FLUKE 87-5","price":"R$3.070,00","price_float":3070,"idCombination":0,"idAddressDelivery":0,"is_gift":false,"hasAttributes":false,"hasCustomizedDatas":false,"customizedDatas":[]}],"discounts":[],"shippingCost":"R$41,04","shippingCostFloat":41.04,"wrappingCost":"R$0,00","nbTotalProducts":1,"total":"R$3.111,04","productTotal":"R$3.070,00","freeShipping":"R$0,00","freeShippingFloat":0,"hasError":false} --- Does anyone know how can we fix it? Link to comment Share on other sites More sharing options...
valo Posted May 6, 2015 Share Posted May 6, 2015 Since almost every link is rewriten by php and .htaccess redirect every link by index.php it can be done using php insted of htaccess. Create new file called old_site_redirect.php and pase code below (change old_url and new url to real path $url_redir_maps = array( '/some_old_url.html' => '/some_new_url', '/old_url2' => '/new_url2', (...and so on) ); if(in_array(@$_SERVER['REQUEST_URI'], array_keys($url_redir_maps))){ header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$url_redir_maps[@$_SERVER['REQUEST_URI']]); exit; } Now in prestashop index.php include this file on top of this file so it looks like this: <?php require_once('old_site_redirect.php'); require(dirname(__FILE__).'/config/config.inc.php'); Dispatcher::getInstance()->dispatch(); Hi, Have done exactly like you tell, but the redirect don´t want work. i entry the old_site_redirect.php but the redirect don´t want work. Maybe i have a systax error by the URL. What is the exactly syntax of the redirect URL. I try this one $url_redir_maps = array( 'http://www.shop.de/de/how/product22.html' => 'http://www.shop.de/de/how/product33.html' ); http://www.shop.de/de/how/product22.html == is the old URL (not work) http://www.shop.de/de/how/product33.html == is the new URL (work in browser) Thank you and sorry for the newbe question :-) Link to comment Share on other sites More sharing options...
Sprenzy Posted May 14, 2015 Share Posted May 14, 2015 Hi valo, You are forgetting your comma (,) at the end of the line. Here is my code below which works: $url_redir_maps = array('/content/7-parts-and-components' => 'https://www.sparepowerafrica.com/12-parts-components'); Link to comment Share on other sites More sharing options...
valo Posted May 15, 2015 Share Posted May 15, 2015 (edited) Hi valo, You are forgetting your comma (,) at the end of the line. Here is my code below which works: $url_redir_maps = array( '/content/7-parts-and-components' => 'https://www.sparepowerafrica.com/12-parts-components' ); Hi, which comma do you mean, sorry don´t see it. My CODE: $url_redir_maps = array( 'http://www.shop.de/de/rok/product22.html' => 'http://www.shop.de/de/how/product33.html' ); Edited May 15, 2015 by valo (see edit history) Link to comment Share on other sites More sharing options...
Sprenzy Posted May 15, 2015 Share Posted May 15, 2015 Hi, which comma do you mean, sorry don´t see it. My CODE: $url_redir_maps = array( 'http://www.shop.de/de/product22.html' => 'http://www.shop.de/de/how/product33.html' ); Hi valo, Apologies, seems as though i forgot to put the comma:) '/some_old_url.html' => '/some_new_url',(comma) Link to comment Share on other sites More sharing options...
valo Posted May 16, 2015 Share Posted May 16, 2015 (edited) mhhhh,mhhhhhhh,mhhhhhhhhhhhhoooohhhhhhhhhhhh can not finde my mistake.Have added the coma, no result. the redirect don´t want work. My CODE: $url_redir_maps = array( 'http://www.shop.de/shopold/de/product22.html' => 'http://www.shop.de/shopnew/de/product33.html', '/shopold/de/product55.html' => 'http://www.shop.de/shopnew/de/product77.html', ); Have tryed again. I entry the old_site_redirect.php but the redirect don´t want work. Edited May 16, 2015 by valo (see edit history) Link to comment Share on other sites More sharing options...
lavalava Posted June 5, 2015 Share Posted June 5, 2015 Work for me ecommdev metod PS1.6.0.14 Link to comment Share on other sites More sharing options...
kyrios Posted June 5, 2015 Share Posted June 5, 2015 @valo Why don't you use rewriterule? old url is still using Prestashop? It will be just 1 line mod Link to comment Share on other sites More sharing options...
valo Posted June 9, 2015 Share Posted June 9, 2015 @valo Why don't you use rewriterule? old url is still using Prestashop? It will be just 1 line mod Hi, you mean to edit the NEW url to the OLD url ? In my new Shop i use 2 lenguages, also the NEW url have DE or EN in the syntax. The OLD url it doesn´t have. Link to comment Share on other sites More sharing options...
kyrios Posted June 9, 2015 Share Posted June 9, 2015 (edited) what is default lang? DE or EN? Yoursite, is it .com? or .net? you can use rewriterule or redirectmatch. I'll try to give you the codes for rewriterule or redirectmatch. Edited June 9, 2015 by kyrios (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted June 9, 2015 Share Posted June 9, 2015 I like this solution. having to deal with .htaccess makes me think of the 80's/90's http://addons.prestashop.com/en/seo-prestashop-modules/11399-301-302-303-url-redirects-seo.html 1 Link to comment Share on other sites More sharing options...
valo Posted June 17, 2015 Share Posted June 17, 2015 what is default lang? DE or EN? Yoursite, is it .com? or .net? you can use rewriterule or redirectmatch. I'll try to give you the codes for rewriterule or redirectmatch. Hi Kyrios, Thank you for your answer. Also I use DE as my default language. My OLD site has have .de and the NEW Site .de too. I use in my new Shop Multishop-system too, may that is the problem. Thank you Link to comment Share on other sites More sharing options...
jaffamuffin1 Posted June 18, 2015 Share Posted June 18, 2015 hi, sorry for hijacking your post. I downloaded prestashop 2 days ago and I am having troubles with htaccess, index php and url... Webhost says DNS is fine. They advise to put '#' before any line that had the word "RewriteRule" but it didnt work. I tried replacing the old url with new one as advised on this post but that didnt work either. I am a complete novice with Cpanel and codes. When I set up the shop, it did ask to confirm something in SEO/URL and it has not worked since. I cant remember what I did wrong... I would appreciate any advice. Thank you for your time Here is what my htaccess reads; # ~~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: EVapourateRewriteRule . - [E=REWRITEBASE:/]RewriteRule ^api$ api/ [L]RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]# AlphaImageLoader for IE and fancyboxRewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]#Domain: www.evapourate.comRewriteRule . - [E=REWRITEBASE:/]RewriteRule ^api$ api/ [L]RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]# AlphaImageLoader for IE and fancyboxRewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]</IfModule>AddType application/vnd.ms-fontobject .eotAddType font/ttf .ttfAddType font/otf .otfAddType 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 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 again Link to comment Share on other sites More sharing options...
kyrios Posted June 18, 2015 Share Posted June 18, 2015 Hi Kyrios, Thank you for your answer. Also I use DE as my default language. My OLD site has have .de and the NEW Site .de too. I use in my new Shop Multishop-system too, may that is the problem. Thank you And your website is? You shall write 3-4 lines example of old url to new url you wan to accomplish it will be easier for us to understand what you want to accomplish. Link to comment Share on other sites More sharing options...
jetx Posted June 19, 2015 Share Posted June 19, 2015 I like this solution. having to deal with .htaccess makes me think of the 80's/90's http://addons.prestashop.com/en/seo-prestashop-modules/11399-301-302-303-url-redirects-seo.html That is interesting and CSV import even... I did it the old fashioned way and laboriously entered each one. Thanks for the link. Link to comment Share on other sites More sharing options...
protechtrader Posted July 25, 2015 Share Posted July 25, 2015 Since almost every link is rewriten by php and .htaccess redirect every link by index.php it can be done using php insted of htaccess. Create new file called old_site_redirect.php and pase code below (change old_url and new url to real path $url_redir_maps = array( '/some_old_url.html' => '/some_new_url', '/old_url2' => '/new_url2', (...and so on) ); if(in_array(@$_SERVER['REQUEST_URI'], array_keys($url_redir_maps))){ header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$url_redir_maps[@$_SERVER['REQUEST_URI']]); exit; } Now in prestashop index.php include this file on top of this file so it looks like this: require_once('old_site_redirect.php'); require(dirname(__FILE__).'/config/config.inc.php'); Dispatcher::getInstance()->dispatch(); I've checked on PS 1.6 and works great. Hope this help someone Hey, it helped me and works great thanks! I just wanted to ask, is there anyway to make it work with wildcards similar to how rewriterule would have worked? For example: /some_old_CATEGORY/* => /some_new_CATEGORY/* I know it isnt as simple as that, but is their a easy PHP change to this code to make it work with wildcards in a similar manner? Link to comment Share on other sites More sharing options...
Mr Rick Posted August 1, 2015 Share Posted August 1, 2015 Hi, PrestaToolkit offers URL redirects manager which can do 301,302,303 type of redirects. Please do review this module and send any suggestions you have. Details: http://addons.prestashop.com/en/seo-prestashop-modules/19790-url-redirects.html Link to comment Share on other sites More sharing options...
biter Posted November 19, 2015 Share Posted November 19, 2015 Hey! I have a queston in topic. I had wordpress blog on my domain http://libernova.pl, and now i have prestashop. How should i do redirect. htaccess method or this one with php file you were talking about. I want to redirect all old links to main site. For example this link: http://libernova.pl/index.php/miejsce-chrzescijanskiego-fan-fiction-w-literaturze/ It is a bit important becouse i have 27 pages on my shop for now, and 54 Error 404 links. Can you help me, best on example becouse my knowing php is basic. Link to comment Share on other sites More sharing options...
espacioled Posted November 19, 2015 Share Posted November 19, 2015 hi, its working good but makes page very heavy and runs slowly, its normal? thanks Link to comment Share on other sites More sharing options...
biter Posted November 19, 2015 Share Posted November 19, 2015 In my shop this php is not working, i made php file, put it into root directory, and revrite index.php from root directory as you show, but 301 is not working, show me please on the example of my link how to write it. Link to comment Share on other sites More sharing options...
gabrielio Posted September 25, 2016 Share Posted September 25, 2016 Since almost every link is rewriten by php and .htaccess redirect every link by index.php it can be done using php insted of htaccess. Create new file called old_site_redirect.php and pase code below (change old_url and new url to real path $url_redir_maps = array( '/some_old_url.html' => '/some_new_url', '/old_url2' => '/new_url2', (...and so on) ); if(in_array(@$_SERVER['REQUEST_URI'], array_keys($url_redir_maps))){ header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$url_redir_maps[@$_SERVER['REQUEST_URI']]); exit; } Now in prestashop index.php include this file on top of this file so it looks like this: require_once('old_site_redirect.php'); require(dirname(__FILE__).'/config/config.inc.php'); Dispatcher::getInstance()->dispatch(); I've checked on PS 1.6 and works great. Hope this help someone Thank you. This is the best solution for me for redirecting the logout page from '/?mylogout=' to '/my-account/?mylogout=' You have no idea how much i`ve searched for. Perfect redirect so far, it actually works. Link to comment Share on other sites More sharing options...
20bekhar Posted January 15, 2020 Share Posted January 15, 2020 I have an error that is related to Page has links to redirect: It is about the account page: https://20bekhar.com/my-account and https://20bekhar.com/login?back=my-account please help me I dont know How I can fix it. Link to comment Share on other sites More sharing options...
obewanz Posted January 5, 2022 Share Posted January 5, 2022 I noticed that the module options are all $84.99 or more... you can purchase a similar module at mypresta.eu for 29.99 euro or $51 usd. The prestashop marketplace seems to have been lined with gold and marble walls or something. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now