我有两个文件夹:
- 文件夹 A 中是托管具有域名的页面的站点
www.mydomain
。 - 文件
mydomain.com
夹 B 中是带有域名的站点demo.mydomain.com
我该怎么做?我尝试了以下方法,但没有效果。
server {
listen 80;
server_name example.com;
rewrite ^/(.*) http://www.example.com/$1 permanent;
}
server {
listen 80;
server_name www.example.com example.com;
root /var/www/html/folderA;
}
server {
listen 80;
server_name ~^(.*)\.example\.com$;
# Sets the correct root
root /var/www/html/folderB;
}
答案1
非常感谢你的帮助,我终于解决了这个问题
server {
listen 80;
server_name example.com www.example.com;
root /var/www/html/folderA;
index index.php index.html;
rewrite ^/folderB/(.*)$ http://demo.example.com/$1? permanent;
location /images {
autoindex on;
}
}
server {
listen 80;
server_name demo.example.com;
root /var/www/html/folderB;
index index.php index.html;
location /images {
autoindex on;
}
}