Nginx伪静态规则怎么设置

如题所述

1、输入以下命令
cd /alidata/server/nginx/conf/rewrite再输入ll
看看是不是像下面截图的一样。
2、这些就是伪静态规则文件。我们打开phpwind.conf看看。
已经在rewrtie目录下配置了常见程序的伪静态规则。可以直接调用。
3、如果没有就按照程序名.conf的命名方式新建一个配置文件
配置文件搞清楚了,你可能会说好像网站伪静态还是没效果啊。别着急,因为伪静态规则是需要被网站配置文件调用才行的。
4、输入以下命令
cd /alidata/server/nginx/conf/vhosts
进入到网站配置目录
5、打开配置文件
修改好伪静态调用文件
下面测试下我们配置的文件是否正确吧输入
nginx: the configuration file /alidata/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /alidata/server/nginx/conf/nginx.conf test is successful
如果出现以上两句话就说明配置成功了。下面重启下nginx就可以了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-01-25

这是我的discuz的伪静态设置 ,可以参考一下

        location / {
            root   /home/www/web;
            index  index.html portal.php index.htm index.php;
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
return 404;
}
        }

本回答被提问者和网友采纳
相似回答