S
S
Sergey2018-03-21 13:57:32
htaccess
Sergey, 2018-03-21 13:57:32

How to get rid of signs? in url?

Good day!
Tell me, please, in such a situation:
if you enter in the url, for example
, mysite.ru/catalog ? /something
then fulfills the catalog route - the page is displayed. Dubbing, however.
How to redirect from catalog?/something to just catalog/something, i.e. get rid of the question marks?
tried like this:
RewriteRule ^(.+)\?(.+)$ /$1$2 [R=301,L]
it doesn't work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2018-03-21
@Prow1er

Everything after ? that is GET parameters. In turn, Get is not part of the url and does not fall into %{REQUEST_URI}

# 301 --- http://www.test.com/faq.html?faq=13&layout=bob => http://www.test2.com/faqs.html
RewriteCond %{HTTP_HOST} ^www\.test\.com$
RewriteCond %{QUERY_STRING} (^|&)faq\=13($|&)
RewriteCond %{QUERY_STRING} (^|&)layout\=bob($|&)
RewriteRule ^faq\.html$ http://www.test2.com/faqs.html? [L,R=301]

# 301 --- http://www.test3.com/faq.html?faq=13&layout=bob => bbq.html
RewriteCond %{QUERY_STRING} (^|&)faq\=13($|&)
RewriteCond %{QUERY_STRING} (^|&)layout\=bob($|&)
RewriteRule ^faq\.html$ /bbq.html? [L,R=301]

Please note that both selecting and deleting the get parameter simply won’t work .
To delete it, just specify a null get parameter by putting a question mark at the end of the url %1 - can be simplified to in this example, the sequence of these parameters does not matter
(^|&)layout\=bob($|&)layout\=bob

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question