S
S
ssclock2016-03-09 11:41:41
htaccess
ssclock, 2016-03-09 11:41:41

How to setup .htaccess to redirect from old domain to new domain without www?

The problem is this.
In Firefox, this combination of rules causes the redirect to http:// www .new.rf, which doesn't work for me (for which there are two lines at the end).
In Chrome, from http:// (www)old.ru, it also redirects immediately to http:// new.rf, as required.
How to make a redirect from
1) http:// www.old.ru
2) http:// old.ru
3) http:// www.new.ru
redirect strictly to http:// new.ru for Firefox ?
Using punycode does not help in any way, I checked it.

RewriteCond %{HTTP_HOST} ^old\.ru$ [NC]
RewriteRule ^(.*)$ http://новый.рф/$1 [R=301,L]

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

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
ssclock, 2016-03-09
@ssclock

Found a solution through combining queries and using the OR operand.
Here it redirects immediately if the domain is old and through www, and if the old one is without www, and if the new one is through www.
I have not seen such solutions on the net, although in general everything is trite here.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^old\.ru$ [OR]
  RewriteCond %{HTTP_HOST} ^www\.old\.ru$ [OR]
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://новый.рф/$1 [L,R=301]
</IfModule>

In punycode, of course.

Z
zooks, 2016-03-09
@zooks

Already a thousand times it was:
https://toster.ru/search?q=%D1%80%D0%B5%D0%B4%D0%B...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question