S
S
ssrdop2017-07-18 10:35:04
PHP
ssrdop, 2017-07-18 10:35:04

How to write a redirect for htaccess with cnc?

For example, there are pages
mysite.ru/catalog/obuv/kozzh?PAGEN_1=12 on mysite.ru/catalog/obuv/kozzh
mysite.ru/catalog/obuv/plohaia?PAGEN_1=149 on mysite.ru/catalog/obuv/plohaia
etc. What needs to be written in htaccess?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Viktor Taran, 2017-07-18
@ssrdop

GET is not part of the url by this and

RewriteCond %{QUERY_STRING} (^|&)PAGEN_1\=12($|&) [NC]
RewriteRule ^catalog/obuv/kozzh$ catalog/obuv/kozzh? [L,R=301]

the question at the end will remove the get parameter.
Also, make conditions on the site that if there is a get request on the page, then insert a real canonical on the page without a get parameter.
Disable paging in robots.txt
If you need to make a lot of such redirects, then
https://www.donatstudios.com/RewriteRule_Generator
And don't forget to mark as resolved.

L
Larisa Moroz, 2017-07-18
@larisamoroz

RewriteCond      %{QUERY_STRING}    ^PAGEN_1=
RewriteRule      (.*)               $1?     [L,R]

M
Mikhail Zakharov, 2017-07-18
@cashalot

This is not for you in .htaccess, but in a file like page.php, which, using this get-parameter, selects news from the database with such a value in the url field, for example.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question