A
A
Andrey Borchik2016-11-14 14:10:47
HTML
Andrey Borchik, 2016-11-14 14:10:47

How to make a redirect in Prestashop?

There is a site arthata.by on prestashop
It has a product category arthata.by/module
The question began to excite. It seems to me that some people go to the page arthata.by/module without a slash at the end /
And it has a 404 error
How to make a redirect? in htaccess? In the press itself? How to avoid duplicate page for SEO?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Ilyasov, 2016-11-19
@andryu6ka

I'll start with the fact that it just so happened that in Prestashop, usually, pages end without a slash.
So check your modules and make sure they make pages without trailing slashes.
If you still need to make some specific static page with a slash, so that there are no duplicates, then add a 301 (full) redirect line for this page to .htaccess:
and so that this entry does not get lost when updating the cache, in the file ../your_site/classes/Tools.php
find the entry: fwrite($write_fd, "</IfModule>\n\n");(or similar, at about line 2500) .
Insert below it:

fwrite($write_fd, "Redirect 301 /module /module/\n");

I came up with a more global and correct option through mod_rewrite :
in the file ../your_site/classes/Tools.php
we find the entry:
fwrite($write_fd, 'RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]'."\n\n");

insert after it:
fwrite($write_fd, "RewriteCond %{REQUEST_URI} ^/module$\n");
fwrite($write_fd, "RewriteRule .+ ".(Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://')."".$domain."/module/ [R=301,L]\n\n");

Update .htaccess by flipping the " Apache Optimization " switch in " Advanced Settings >> Performance "

A
Alexander, 2016-11-14
@alexmixaylov

it is better to make a redirect in htacceess so
that there are no duplicates,
just remember that this file is generated automatically
and if you turn off the CNC and then turn it on, the changes will be overwritten

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question