P
P
Pavel2015-12-08 14:54:40
Apache HTTP Server
Pavel, 2015-12-08 14:54:40

How to set a redirect 301?

There is a site with such a domain: domain.ru, you need to redirect all its pages to domain.ru.com

RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC]
RewriteRule ^([^/]+) $1 [L]
RewriteCond %{HTTP_HOST} ^domain\.ru
RewriteRule ^(.*)$ http://domain.ru.com/$1 [R=301,L]

But there is a cyclic redirection. As I understand it, the new domain, as it were, also falls under RewriteCondand redirects again.
How to make a correct redirect? (in fact, this is a move to a new domain)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Yuri, 2015-12-08
@xtreme

RewriteCond %{HTTP_HOST} ^domain\.ru$
Logically, it should be like this if you have both domains on the same server.

Z
zooks, 2015-12-08
@zooks

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.net/$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