url rewrite是Apache中一个很有用的功能,因为手上的项目要用到该功能,所以今天安装测试了一下.
1. 在http.conf文件中,找到LoadModule rewrite_module modules/mod_rewrite.so,把前面的注释(#)去掉.
2. 在<Directory/>中,设置 AllowOverride All
3. 在网页文件夹中新建一个.htaccess文件,里面进行url rewrite配置: (Windows平台不能创建.htaccess这样以.开头的文件,我是用Eclipse创建的)
DirectoryIndex index.htm index.php
RewriteEngine on
# company index a-z pattern
RewriteRule ^aaa.html$ /aaa.php
这样当你在浏览器中输入aaa.html的时候实际是访问aaa.php.