I
I
Ilya Derevyannykh2021-09-14 18:10:44
htaccess
Ilya Derevyannykh, 2021-09-14 18:10:44

How to make a redirect from all pages of one domain to the main page of another domain?

From the site https://sto-tonn.com/contact/ I do it for a hundred tons.rf

I tried
RewriteRule ^([^/]+) $1 [L]
RewriteCond %{HTTP_HOST} ^sto-tonn\.ru
RewriteRule ^(.* )$ https://hundredtonn.rf/$1 [R=301,L]

and now it costs
RewriteCond %{REQUEST_URI} (.*)
RewriteRule ^(.*)$ http://hundredtonn.rf [L,R =301]

But the redirect only works from sto-tonn.ru, not from other pages

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-09-14
@Ylia_dr

"hundred tons.rf" in punycode will be "xn--m1aabangb.xn--p1ai"
Redirect from all pages to the main page:

RewriteEngine on

RewriteRule ^ https://xn--m1aabangb.xn--p1ai/  [R=301,L]

Put at the beginning of the .htaccess file above the rest of the rules.
If you need an additional condition for the domain:
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(?:www\.|)sto-tonn\.ru  [NC]
RewriteRule ^ https://xn--m1aabangb.xn--p1ai/  [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question