简单配置Apache的伪静态,只需要三个步骤:
第一步:打开 Apache 的配置文件 httpd.conf,
找到
#LoadModule rewrite_module modules/mod_rewrite把前面的#号去掉,使之有效,改完后代码如下:
LoadModule rewrite_module modules/mod_rewrite
第二步:找到
# AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None
把AllowOverride None改为AllowOverride All,使之支持.htaccess。
# AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All
第三步:重启Apache服务器。
下面我们可以做个测试,我写一个简单的.htaccess文件,放到WEB目录下,代码如下:
RewriteEngine on RewriteRule ^(.*)$ index.php
以上重写的规则就是不管您输入WEB目录下的什么文件地址都会重写到index.php。具体重写规则可以参考一下”正则表达式”的相关文档,这里就不一一介绍了。
Leave a Reply