A
A
Artemy Zheman2016-11-05 14:25:26
htaccess
Artemy Zheman, 2016-11-05 14:25:26

How to make it not redirect?

Hello!
We moved the site to a new domain, the urls remained the same.
To do this, write something like

RewriteEngine on
RewriteRule (.*) http://www.newdomain.ru/$1 [R=301,L]

Now, when visiting oldsite.ru/213, it redirects to newdomain.ru/213
Everything is correct, but we want robots.txt to open on the old site without a redirect.
How to add an exception so that oldsite.ru/robots.txt works like this and does not redirect to newdomain.ru/robots.txt?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-11-05
@alsopub

If both sites are handled by the same .htaccess, then you can try

RewriteEngine on
RewriteBase /

RewriteCond  %{HTTP_HOST} oldsite.ru$
Rewriterule ^robots.txt$ robots-oldsite.txt [L]

RewriteRule (.*) http://www.newdomain.ru/$1 [R=301,L]

And in robots-oldsite.txt, respectively, put the "old" robots.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question