Apache Mod_Rewrite URL重写 伪静态化
测试环境:
Windows xp
XAMPP for windows
配置步骤:
第一步:找到apache的配置文件httpd.conf(文件在conf目录下)
第二步:让服务器支持mod_rewrite
打开httpd.conf,找到#LoadModule rewrite_module modules/mod_rewrite.so把#去掉
找到<Directory />下AllowOverride None 改成 AllowOverride All
对于不同的网址,需要在APACHE中增加如下内容
<Directory “D:/xampp/htdocs/test”>
AllowOverride All
</Directory>
第三步:重启apache服务器。
第四步:在需要URL重写的网站目录下放一个.htaccess文件,并输入需要伪静态的页面正则表达式映射
URL正则表达式如下:
RewriteEngine on
RewriteRule default.html default.php
RewriteRule (\d+).html$ tabslimit.php?id=$1
注:URL规划的方案例子:
localhost/tabslimit.php?id=1
映射为
localhost/1.html
配置结束。
参考:
http://faq.comsenz.com/viewnews-12
http://www.leapsoul.cn/?p=25
http://www.leapsoul.cn/?p=986