码迷,mamicode.com
首页 > Web开发 > 详细

APACHE的伪静态设置

时间:2015-06-21 20:55:44      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

1、配置httpd.conf

 

1 #LoadModule rewrite_module modules/mod_rewrite.so  开启
2 
3      LoadModule rewrite_module modules/mod_rewrite.so
4 
5    #Include conf/extra/httpd-vhosts.conf 开启
6 
7      Include conf/extra/httpd-vhosts.conf

 

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

    

 1 <VirtualHost 127.0.0.1:80>
 2 
 3   ServerAdmin webmaster@dummy-host.example.com
 4   DocumentRoot "D:/myphpwork/wamp/www"
 5   ServerName localhost
 6   ServerAlias www.dummy-host.example.com
 7   ErrorLog "logs/dummy-host.example.com-error.log"
 8   CustomLog "logs/dummy-host.example.com-access.log" common
 9 
10   #重写规则
11   RewriteEngine on
12 
13   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}!-d
14 
15   RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}!-d
16   RewriteRule ^/test/([1-9]+).html$ /test.php?id=$1
17  </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

APACHE的伪静态设置

标签:

原文地址:http://www.cnblogs.com/JeromeZ/p/4592316.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!