-
关于Nginx伪静态代码
-
-
看看APACHE转Nginx代码挺简单的,但是改了后怎么都不能实现伪静态,真捉急!
Apache代码:
RewriteRule ^index\.html$ index.php [L]
RewriteRule ^([a-z]+)/([0-9]+)\.html$ index.php?c=$1&a=detail&id=$2 [L]
RewriteRule ^home/([0-9]+)$ index.php?c=home&uid=$1 [L]
RewriteRule ^wap$ wap.php [L]
转换成Nginx代码:
location /
{
rewrite "^/index\.html$" index.php last;
rewrite "^/([a-z]+)/([0-9]+)\.html$" index.php?c=$1&a=detail&id=$2 last;
rewrite "^/home/([0-9]+)$" index.php?c=home&uid=$1 last;
rewrite "^/wap$" wap.php last;
break;
}
设置好后,怎么弄都是打不开伪静态页,动态页倒是能打开
请问,nginx伪静态如何设置?
-
3702 次浏览
5 条评论
收藏
5个评论
-
-
244592545
2021-03-31 20:36
-
非常好用
-
-
回复 · 0条回复
-
-
-
--
楼主 2018-01-17 11:49
-
正确的程序:感谢论坛大神“kangs”提供
rewrite ^/index.html$ /index.php last;
rewrite ^/wap$ /wap.php last;
rewrite ^/home/([0-9]+)$ /index.php?c=home&uid=$1 last;
rewrite ^/info/([0-9]+).html$ /index.php?c=info&a=detail&id=$1 last;
rewrite ^/weibo/([0-9]+).html$ /index.php?c=weibo&a=detail&id=$1 last;
rewrite ^/party/([0-9]+).html$ /index.php?c=party&a=detail&id=$1 last;
rewrite ^/diary/([0-9]+).html$ /index.php?c=diary&a=detail&id=$1 last;
rewrite ^/about/([0-9]+).html$ /index.php?c=about&a=detail&id=$1 last;
rewrite ^/case/([0-9]+).html$ /index.php?c=case&a=detail&id=$1 last;
rewrite ^/safety/([0-9]+).html$ /index.php?c=safety&a=detail&id=$1 last;
-
-
回复 · 0条回复
-
-
-
Lee
官方认证帐号 2017-12-09 08:35
-
nginx配置好了伪静态模块吗?
-
-
回复 · 0条回复
-
-
-
--
楼主 2017-12-08 09:28
-
[quote=Lee,169917]改成这样试试
location /
{
rewrite \"^/index\\.html$\" index.php last;
rewrite \"^/(+)/([0-9]+)\\.html$\" index.p...[/quote] 按你这个设置了,重启nginx后还是不行
-
-
回复 · 0条回复
-
-
-
Lee
官方认证帐号 2017-12-08 08:53
-
改成这样试试
location /
{
rewrite \"^/index\\.html$\" index.php last;
rewrite \"^/([a-z]+)/([0-9]+)\\.html$\" index.php?c=$1&a=detail&id=$2 last;
rewrite \"^/home/([0-9]+)$\" index.php?c=home&uid=$1 last;
rewrite \"^/wap$\" wap.php last;
}
-
-
回复 · 0条回复
-
作者信息
-
关注
-
试
免费试用
-
咨询热线
-
咨询热线
020-82299 259
-
在线咨询