R
R
ruslanyugov2020-11-30 16:23:54
htaccess
ruslanyugov, 2020-11-30 16:23:54

How to write a redirect rule in htaccess for a url with a question mark without get parameters?

Redirect status should be 301.

Example:
If we go to https://site.ru ? , then redirect https://site.ru ,
Or
https://site.ru/catalog/product/ ?, redirect https://site.ru/catalog/product/

If the get parameters are present, then of course the redirect should not work.

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-11-30
@ruslanyugov

RewriteCond %{THE_REQUEST} "\? HTTP"
RewriteRule (.*) /$1? [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question