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.

 

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

 

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

  • Like 1

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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:

<?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 :-)

Share this post


Link to post
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)

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

@valo

Why don't you use rewriterule? old url is still using Prestashop? It will be just 1 line mod

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Edited by kyrios (see edit history)

Share this post


Link to post
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

Share this post


Link to post
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

 

Share this post


Link to post
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. 

Share this post


Link to post
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

 

 

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

 

 

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.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More