APACHE的伪静态设置

1、配置httpd.conf

 

 #LoadModule rewrite_module modules/mod_rewrite.so  开启

      LoadModule rewrite_module modules/mod_rewrite.so

    #Include conf/extra/httpd-vhosts.conf 开启

      Include conf/extra/httpd-vhosts.conf

2、配置conf/extra/httpd-vhosts.conf

 <VirtualHost 127.0.0.1:80>

   ServerAdmin webmaster@dummy-host.example.com
  DocumentRoot "D:/myphpwork/wamp/www"
  ServerName localhost
  ServerAlias www.dummy-host.example.com
  ErrorLog "logs/dummy-host.example.com-error.log"
  CustomLog "logs/dummy-host.example.com-access.log" common   #重写规则
  RewriteEngine on   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}!-d   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}!-d
  RewriteRule ^/test/([1-9]+).html$ /test.php?id=$1
 </VirtualHost>

3、通过编写规则,访问www目录下的test.php文件:localhost/test/2.html  就等同于 localhost/test.php?id=2了

4、因为配置了RewriteCond选项所以,就算是访问真正的www/test/2.html也是正常的2.html而不是伪静态页面localhost/test.php?id=2

上一篇:Amoeba For MySQL读写分离


下一篇:Mysql5.6版本内存占用过高解决方法[链接]