D
D
dormannilya2019-10-06 19:06:32
htaccess
dormannilya, 2019-10-06 19:06:32

Setting up redirects?

The point is the following.
There is an old site - http://rukartina.ru/(written on UMI CMS), you need to set up redirects to the new domain in .htaccess - https://rakovgallery.ru/ Initially, in the .htaccess of the old site (rukartina.ru) there are already redirects from http://www.rukartina.ruto the address without www, that is, directly to http://rukartina.ru/
1. Is it correct to prescribe, this redirect:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC]
RewriteRule ^([^/]+) $1 [L]
RewriteCond %{HTTP_HOST} ^rukartina\.ru
RewriteRule ^(.*)$ https://rakovgallery.ru/$1 [R=301,L]

Or do I need to additionally register a redirect for www?
That is, like this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC]
RewriteRule ^([^/]+) $1 [L]
RewriteCond %{HTTP_HOST} ^www.rukartina\.ru$ [NC]
RewriteRule ^(.*)$ https://rakovgallery.ru/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^rukartina\.ru
RewriteRule ^(.*)$ https://rakovgallery.ru/$1 [R=301,L]

2. When writing a redirect from the main page, rukartina.ru redirects to a non-existent page https://rakovgallery.ru/index.php
What's the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-10-06
@dormannilya

2. When writing a redirect from the main page, rukartina.ru redirects to a non-existent page https://rakovgallery.ru/index.php
What's the problem?

This happens when you put a redirect after constructs like RewriteRule ^(.*)$ index.php, so you need to add redirects to the beginning of the file so that they work before other rules.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC]
RewriteRule ^([^/]+) $1 [L]
RewriteCond %{HTTP_HOST} ^www.rukartina\.ru$ [NC]
RewriteRule ^(.*)$ https://rakovgallery.ru/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^rukartina\.ru
RewriteRule ^(.*)$ https://rakovgallery.ru/$1 [R=301,L]

All this can be written shorter.
RewriteEngine On

RewriteCond %{THE_REQUEST} "! /robots\.txt"
RewriteCond %{HTTP_HOST}   ^(www\.|)rukartina\.ru$ [NC]
RewriteRule ^(.*)$ https://rakovgallery.ru/$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