1、mod_rewrite模块的优点
以下URL范例:
很不友好的URL:
http://example.com/user.php?id=5412
比较友好的URL:
http://example.com/user/4512/
非常友好的URL:
http://example.com/user/joe/
以上可由mod_rewrite实行URL转换
2、mod_rewrite模块的启用
1)修改apache主配置文件
vim编辑/etc/httpd/conf/httpd.conf
去掉以下行的注释:
LoadModule rewrite_module modules/mod_rewrite.so
2)重启服务
/etc/init.d/httpd restart
3、检查mod_rewrite模块是否启用
1)在Apache的配置文件中的“DocumentRoot”定义的目录通过vim编辑index.php
并加入如下内容:
<?php phpinfo(); ?>
2)访问主机的http服务会看到如下显示
3)或者用shell命令测试
apachectl -t -D DUMP_MODULES | grep rewrite
显示如下:
rewrite_module (shared)
3、mod_rewrite模块的全局配置文件
本文出自 “老谭linux博客” 博客,请务必保留此出处http://cmdschool.blog.51cto.com/2420395/1719292
原文:http://cmdschool.blog.51cto.com/2420395/1719292