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;
}
}
相关推荐
-
php如何获取get参数,点滴经验分享2025-04-22 02:06:09
-
什么是PHP?培训都学什么?2025-04-22 02:04:15
-
PHP数据类型与常量2025-04-22 01:13:40
-
MySQL 中的反斜杠 \\,真是太坑了2025-04-21 01:42:45
-
mysql修改主键为自增 ,如果自增达到最大值,新增加数据会怎样?
mysql修改主键为自增 ,如果自增达到最大值,新增加数据会怎样?2025-04-21 01:31:46