Apache服务器Rewrite配置
对于一个网站来讲,如果能实现url自已管理是十分有意义的,比如:
/bbs对应~/jiuanblog/bbs/index.php是十分有意思的,一方面可以对外隐藏实现,
即使用网站的用户不知道您的网站是php还是jsp、asp等具体实现,这样对安全是十分有益的。
比如我们想对资源文件不进行重定向,但对实际页面请求就对其进行重定向,则我们可以用如下配置:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^.*$ /bbs
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.gif|\.png|\.jpg|\.jpeg|\.psd)
RewriteRule ^/(.*)$ $1/index.php
说明:
RewriteEngin on打开Rewrite引擎
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^.*$ /bbs下然后继续后续配匹
对于主页的访问,重定向到bbs下的
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.gif|\.png|\.jpg|\.jpeg|\.psd)
RewriteRule ^/(.*)$ $1/index.php
对于非资源文件,则映射到该路径下对应的php文件。
另外还有-f -d等参数,可以判断文件是否存在等。
相关参考:
http://blog.csdn.net/zfrong/archive/2008/11/06/3237190.aspx
http://blog.csdn.net/zfrong/archive/2008/11/06/3237190.aspx
thx
张久安
If you enjoyed this post, make sure you subscribe to my RSS feed!









One Comment, Comment or Ping
realdodo
抢沙发~
Apr 27th, 2009
Reply to “Apache服务器Rewrite配置”
You must be logged in to post a comment.