规则文件内容如下:
location / {
rewrite ^/news/([0-9]*)\.html$ news.php?id=$1 last;
}
我看见有两个nginx配置文件:/etc/nginx/nginx.conf文件和/etc/nginx/sites-available/default文件,请问导入URL Rewrite规则文件时应该把include 规则文件路径;加在以上哪个文件的哪个位置?
我曾尝试在/etc/nginx/sites-available/default的location ~ \.php$ {……}这一段之后加入一条include nginx规则文件路径;,保存,然后重启ubuntu,结果导致整个网站都打不开。
UBUNTU下nginx URL Rewrite规则文件如何导入?
-
- 帖子: 62
- 注册时间: 2011-07-29 19:16
- maplebeats
- 帖子: 378
- 注册时间: 2011-02-16 1:17
- qy117121
- 论坛版主
- 帖子: 50538
- 注册时间: 2007-12-14 13:40
- 系统: Winbuntu
- 来自: 志虚国乌由市
- 联系:
Re: UBUNTU下nginx URL Rewrite规则文件如何导入?
一般是写在站点配置文件中
改成这样试试
rewrite ^/news/([0-9]*)\.html$ news.php?id=$1 last;
改成这样试试
rewrite ^/news/([0-9]*)\.html$ news.php?id=$1 last;
渠月 · QY
本人只会灌水,不负责回答问题
无聊可以点一下→ http://u.nu/ubuntu
Ubuntu 20.04 快速设置指南,请配合浏浏览器自动翻译使用
邮箱 chuan@ubuntu.org.cn
本人只会灌水,不负责回答问题
无聊可以点一下→ http://u.nu/ubuntu
Ubuntu 20.04 快速设置指南,请配合浏浏览器自动翻译使用
邮箱 chuan@ubuntu.org.cn
-
- 帖子: 62
- 注册时间: 2011-07-29 19:16
Re: UBUNTU下nginx URL Rewrite规则文件如何导入?
谢谢,问题已解决。/etc/nginx/sites-available/default文件里原来已经有了location / {……},只需要把规则rewrite ^/news/([0-9]*)\.html$ news.php?id=$1 last;加到原来的location / {……}里即可,这样就不会重复了。