A
A
Anton Seredny2016-01-14 17:16:05
htaccess
Anton Seredny, 2016-01-14 17:16:05

How to make a redirect from all GET requests for the main page to itself without parameters?

Good day, colleagues! Help me solve a problem that I couldn’t solve with my narrow brain ...
You need to make a 301 redirect to www (both with www and without www) on the main page,
if after the slash http://(www.)site.ru/ there is a sign ?

Those. it is necessary if a request with a GET parameter goes to the main one - it’s easy to redirect to the main one

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Seredny, 2016-01-14
@smidl

I answer my own question:

RewriteCond %{THE_REQUEST} " /\?"
RewriteRule ^ /? [R=301,L]

RewriteCond %{THE_REQUEST} " /\?"
RewriteRule ^  http://www.site.ru/? [R=301,L]

The first option does not change the domain
site.ru/? => site.ru
www.site.ru/? => www.site.ru
The second option always sends to the domain from www
site.ru/? => www.site.ru
www.site.ru/? => www.site.ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question