Jump to content

Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

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

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

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
  • Like 5
Link to comment
Share on other sites

 

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

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

  • 3 months later...

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

  • 1 month later...

 

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

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(
);
Edited by valo (see edit history)
Link to comment
Share on other sites

mhhhh,
mhhhhhhh,
mhhhhhhhhhhhh
oooohhhhhhhhhhhh
 
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 by valo (see edit history)
Link to comment
Share on other sites

  • 3 weeks later...

@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

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

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: EVapourate
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api$ api/ [L]

RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]


#Domain: www.evapourate.com
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api$ api/ [L]

RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [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

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

  • 1 month later...

 

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

  • 3 months later...

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

  • 10 months later...

 

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

  • 3 years later...
  • 1 year later...

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...