D
D
Dmitry Bortsov2015-06-10 01:30:55
CMS
Dmitry Bortsov, 2015-06-10 01:30:55

301 redirect. how to implement a redirect from site1.ru/? on site1.ru/?

There was a problem with the redirect.
There is a website, let's call it site.ru. Written in pure php. samopis
Here is .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.site\.ru$ [NC]
RewriteRule ^(.*)$ site.ru/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([^/]+/)*(default|index|main)\.(html|php|htm)\ HTTP/ [NC]
RewriteRule ^(([^/] +/)*)(default|main|index)\.(html|php|htm)$ site.ru/$1 [L,R=301]
RewriteCond %{QUERY_STRING} ^.+$
RewriteCond %{REQUEST_URI} ^/ $
RewriteRule ^(.*)$ site.ru/? [R=301,L]
how to redirect site.ru/? on site.ru/

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artur Nurullin, 2015-06-16
@Splo1ter

You will wait a long time for an answer to such a question, smoke mana

S
ShamblerR, 2015-06-17
@ShamblerR

Let's break it down point by point

RewriteEngine On
 RewriteBase /
тут все понятно

RewriteCond %{HTTP_HOST} ^www\.site\.ru$ [NC]
 RewriteRule ^(.*)$ site.ru/$1 [R=301,L]

here's the kicker. 2 errors are already starting, although not critical
This will be considered a redirect to without www let's not worry, I'll give you a redirect that will work without specifying a domain and looking less miserable.
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]     
       RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(default|index|main)\.(html|php|htm)\ HTTP/ [NC]
 RewriteRule ^(([^/]+/)*)(default|main|index)\.(html|php|htm)$ site.ru/$1 [L,R=301]

It looks like complete crap, what exactly were you trying to do with it?
RewriteCond %{QUERY_STRING} ^.+$
 RewriteCond %{REQUEST_URI} ^/$
 RewriteRule ^(.*)$ site.ru/? [R=301,L]

As far as I understand, this is again a miserable continuation of a self-written CNC in addition to ? at the end
, write down what exactly in your opinion each block does, we will bring to life the existing ... mmm how to say "structure"
And then we will think what was wrong.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question