L
L
lexstile2017-05-30 15:59:03
htaccess
lexstile, 2017-05-30 15:59:03

Redirect from slash to without slash in get-parameters?

There are pages like site.ru/?id=100
The search includes pages like site.ru/?id=100/
Question:
How to make a redirect from pages with a slash to without?
Currently using:
RewriteCond %{REQUEST_URI} !\?
RewriteCond %{REQUEST_URI} !\&
RewriteCond %{REQUEST_URI} !\=
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_URI} !\/$
RewriteRule ^(.*[^\/])$ /$1/ [R=301,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-05-30
@lexstile

get is not part of the url, {REQUEST_URI} is not corny to it.

# 301 --- http://www.mydefile.ru/company/?section=torgovlya&PAGEN_1=9 => http://www.mydefile.ru/about/
RewriteCond %{QUERY_STRING} (^|&)section=torgovlya($|&)
RewriteCond %{QUERY_STRING} (^|&)PAGEN_1=9($|&)
RewriteRule ^company/$ /about/? [L,R=301]

Pay attention to ?at the end of the rewrite rule, it will remove the get itself.
Also, if you need to redirect TO a page with GET, do not forget to escape it
Don't forget to put solved

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question