G
G
Gabe_B2016-05-07 11:26:30
Apache HTTP Server
Gabe_B, 2016-05-07 11:26:30

How to display the main site on all subdomains?

Good day! There was a need to create a geolocation with a redirect to the subdomain of the city.
In fact, at this stage, you need to display the same site on all subdomains. Can this be implemented?
Tried more than a dozen options - it does not work.
The idea is this: a user visits site.ru, determines his city and offers to go to a subdomain, for example moscow.site.ru
Question: How to display a mirror of the main site on moscow.site.ru without redirecting (with saving the address)? In other words - show on moscow.site.ru what is on site.ru ?
There can be a large number of such subdomains, some can be deleted, some added, but they should display only the main page.
*.site.ru is written in the host settings
On one of the forums I found this option -
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.site\.ru
RewriteCond %{HTTP_HOST} ([^.]+)\.site\. en [NC]
RewriteRule ^/?$ "/" [L]
On one of the hosts, this option really works. But unfortunately, on the desired host was not successful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Agaltsov, 2016-05-11
@Archusha

well, the simplest solution is to close all subdomains on the same folder where the site is located.
And in the site engine, parse the city from the URL.

P
PerfectoWeb, 2016-05-15
@PerfectoWeb

Did you understand correctly that you need to display each city in the subdomain so that the script is processed from the main directory?
1) Add an entry in the DNS settings of the CNAME domain: *.site.com CNAME site.com.
2) Get data from the $_SERVER array and determine the selected city.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question