nginx配置不生效的问题解决
先看正确的nginx配置文件的主要部分:
注意 ^~ 的部分,这样就根目录,a路径,还有b路径都能生效了。
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location ^~/a {
alias /home/www/a; //此处为a的路径
index index.html;
}
location ^~/b {
alias /home/www/b; //此处为a的路径
index index.html;
}
}
如果这样写是不生效的:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /a { // 这里不生效
alias /home/www/a; //此处为a的路径
index index.html;
}
location /b { // 这里不生效
alias /home/www/b; //此处为a的路径
index index.html;
}
}
相关推荐
-
PHP8种变量类型的详细讲解2025-02-22 00:32:24
-
php+apache 和 php+nginx的区别2025-02-22 00:21:27
-
PHP:与workerman结合实现定时任务2025-02-22 00:15:57
-
Nginx的Rewrite规则与实例2025-02-22 00:15:39
-
MySql中身份证字段的简单脱敏介绍2025-02-22 00:15:36