O
O
Otrivin2017-02-22 20:35:38
htaccess
Otrivin, 2017-02-22 20:35:38

How to redirect a page with a parameter in htaccess?

Hello!
There is a URL that is a duplicate of the main page:

http://site.ru/?view=featured&layout=rt_fresco:frescofeatured

How to write a rule in htaccess for 301 redirects from this URL to the main ( site.ru)?
Tried like this:
RewriteCond %{QUERY_STRING} ^layout=rt_fresco:frescofeatured
RewriteRule ^http://site.ru(.*)$ http://czm-krasnodar.ru? [R=301,L]

, nothing happens, the source address is opened.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Otrivin, 2017-02-22
@Otrivin

Got it!
The rules are "plused", the RewriteRule condition will be met if all RewriteConds are true. First, we check the presence of some elements in the url ({QUERY_STRING}), then we replace the entire internal link with /. Your Cap.
RewriteCond %{QUERY_STRING} view=featured [NC]
RewriteCond %{QUERY_STRING} layout=rt_fresco [NC]
RewriteRule .* /? [R=301,L]
Article helpedhttp://max22.ru/server/htaccess/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question