S
S
steamn2020-05-30 14:18:06
PHP
steamn, 2020-05-30 14:18:06

Set up a redirect from a subdomain to a page on another site?

There is a site with the address: main-site.ru.
A subdomain with the address subdomain.main-site.ru has been created that leads to another server with a dedicated ip (an A record with the ip has been created)
You need to create another subdomain of the subdomain2.main-site.ru type that would open a specific page with subdomain.main- site.ru (to get it like this - subdomain.main-site.ru/some-url )
at this address - subdomain.main-site.ru/some-url the page opens, but it also needs to open at the address: subdomain2.main -site.ru

How to do it right?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2020-05-30
@dodo512

If you need a 301 redirect

RewriteCond %{HTTP_HOST} ^subdomain2\.main-site\.ru$  [NC]
RewriteRule ^$ http://subdomain.main-site.ru/some-url [R=301,L]

If you need proxying.
RewriteCond %{HTTP_HOST} ^subdomain2\.main-site\.ru$  [NC]
RewriteRule ^$ http://subdomain.main-site.ru/some-url [P]

Or on the php side use curl.

V
Viktor Taran, 2020-05-30
@shambler81

if subdomain2.main-site.ru should go to subdomain.main-site.ru with 301, this is a simple redirect.
If you want to give content from that site on your domain, then
1. you have nginx - then you can proxy and use subdomain.main-site.ru as a backend
2. Using php proxy
3. mod_proxy + .haccess

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question