E
E
es1082020-02-05 14:31:05
htaccess
es108, 2020-02-05 14:31:05

How to set up a redirect for the main page?

Hello!
You need to set up a 301 redirect for the Home page so that when you enter the following addresses, not only the redirect is carried out, but the code 301 is also given:
from
https://www.mysite.ru/ - now for this view, there is a redirect, but it gives the code 200
https: //www.mysite.ru/?
at
https://www.mysite.ru

Thank you in advance for your help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wisgest, 2020-02-08
@wisgest

As I understand it, %{QUERY_STRING}requests ending in a single question mark cannot be distinguished from those without it, but you can use the variable %{THE_REQUEST}containing the full request (see httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rew.. . ):

RewriteCond %{THE_REQUEST} ^\S+\s+/\?\s
RewriteRule "" http://example.com/? [R=301,L]

As for http://example.com/and http://example.com, the second address is converted by the browser to the first one and the server receives an indistinguishable request, so there is nothing to redirect.

M
makol, 2020-02-05
@mak-oleg

Hello, did you ask google? Look here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question