Answer the question
In order to leave comments, you need to log in
How to link a subdomain to a website directory?
Good morning.
Suppose I have site.ru
. I want the food.site.ru
user to see the directory site.ru/food
when navigating through the subdomain, and when navigating through the subdomain drinks.site.ru
, the site.ru/drinks directory is shown.
How to set it up with a simple redirect through .htaccess
- I understand. Is it possible to make the subdomain stay in the address bar? The directories have one-page sites and any navigation through them is not needed.
I will be grateful for any advice. Thanks :)
Answer the question
In order to leave comments, you need to log in
nginx config
server {
listen 80;
server_name site.ru *.site.ru;
location / {
if ($host ~* ^(food|drinks)) { # или ^(.+)\. - для любого
proxy_pass http://site.ru/$1;
}
}
}
for apache like this
<VirtualHost *:80>
ServerName www.site.ru
ServerAlias *.site.ru
VirtualDocumentRoot "D:/www/vhosts/site.ru/%1"
</VirtualHost>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question