U
U
UsualSon2016-05-11 11:24:10
Apache HTTP Server
UsualSon, 2016-05-11 11:24:10

How to remove the question mark at the end of a URL?

Pages like this appeared in Yandex search: www.site.ru/000001.html? with a question mark at the end.
How to make a 301 redirect to the same page using .htaccess without a question mark at the end?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Rumate.Ru, 2017-12-04
@Rumate

#убрать знак вопроса
RewriteCond %{THE_REQUEST} ^[^\s]+\s+[^?]*?\?
RewriteCond %{QUERY_STRING} =""
# Для любых версий Apache:
RewriteRule .? %{REQUEST_URI}? [R=301,L]
# Для Apache 2.4+:
# RewriteRule .? %{REQUEST_URI} [R=301,L,QSD]
это работает только для знака вопроса. Всё, что после него - не убирается

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question