S
S
shevelevdesign2021-02-09 18:50:55
Apache HTTP Server
shevelevdesign, 2021-02-09 18:50:55

How to redirect user from all pages of one domain to page of another domain via htaccess?

It is necessary to make the server redirect from all pages of one domain to a specific page of another domain (about 200+ pages).

For example, the user visits https://test.ru or https://test.ru/page/ etc -> he is always redirected to " https://test2.ru/page3/ "

Apache hosting. Access only .htaccess

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dodo512, 2021-02-09
@shevelevdesign

RedirectMatch 301 ^ https://test2.ru/page3/
Or

RewriteEngine on

RewriteRule ^ https://test2.ru/page3/ [R=301,L]

If you need to check the domain
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(?:www\.)?test\.ru$
RewriteRule ^ https://test2.ru/page3/ [R=301,L]

S
Sergey Sokolov, 2021-02-09
@sergiks

.htaccess- This is for Apache only.
To do what you want with NGINX, you will need to edit its config.
Then restart the service, or send a signal to it to reread the config files.

S
SagePtr, 2021-02-09
@SagePtr

The simplest option in nginx:

server { 
  listen 80;
  listen 443 ssl;
  server_name domain1.ru;
  ssl_certificate ...........;
  ssl_certificate_key ............;
  return 301 https://domain2.ru/page3/;
}

.htaccess here, of course, will not help in any way, it is only for Apache, and you do not have Apache

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question