常见服务器伪静态配置

Apache下伪静态设置

1. 首先找到Apache安装目录,之后找到conf目录下的httpd.conf文件。

2. 添加下面代码到httpd.conf文件中

<Directory /网站根目录>
Options FollowSymLinks
AllowOverride All
</Directory>

3. 在httpd.conf中将LoadModule rewrite_module前面的#号删除;如果您的 Apache 是1.3.x版本还需要将AddModule mod_rewrite.c前面的#删除。

4. 接着配置rewrite策略,一种是通过httpd.conf文件,第二种是通过.htaccess文件。

5. 重新启动Apache

Nginx下伪静态设置

1. 第一种是在nginx.conf(或者在对应的*.conf) 中找到需设置伪静态规则的服务器对应字段,在server{location/{rewrite 正则表达式}}中添加rewrite代码。

2. 第二种则是新建一个.htaccess文件,文件中写好rewrite代码,然后在nginx.conf(或者在对应的*.conf)中的server{}中通过include引入.htaccess文件

include /网站目录/.htaccess; 
posted @ 2020-03-28 21:41  灿钿  阅读(612)  评论(0编辑  收藏  举报