Linux系统实现HTTP服务的URLrewrite功能

Linux系统实现HTTP服务的rewrite功能
 
概述:rewrite功能就是在apache服务器安装时候注意要安装mod_rewrite模块,然后针对其在具体的解释时候以正则表达式进行替换。
 
具体步骤:
1.源码方式安装apache2
 
2.安装后查看/usr/local/etc/apache22/httpd.conf中是否有
  LoadModule rewrite_module libexec/apache22/mod_rewrite.so
  没有就重装apache2,安装时候选mod_rewrite
 
3.编辑 /usr/local/etc/apache22/Includes/httpd-vhost.conf
  ee /usr/local/etc/apache22/Includes/httpd-vhost.conf
 
4.在相应的虚拟目录中加入
  <IfModule rewrite_module>
                RewriteEngine On
                #RewriteLog "/var/log/rewrite_log"
                #RewriteLogLevel 10
                RewriteRule ^(.*)/page_(.*)\.html$ $1/page/index.php?pid=$2
  RewriteRule ^(.*)/(.*)\.html$ $1/index.php?Command=$2
   </IfModule>
 
5.apachectl restart

你可能感兴趣的:(linux,http,系统,服务,休闲)