apache Rewrite拟静态

来源:互联网 发布:33选6所有组合数据库 编辑:程序博客网 时间:2024/05/04 02:13
 

Apache Rewrite拟静态

配置虚拟主机:基于IP+基于端口+基于域名混用

大型虚拟主机(几十万):重定向

1、  目的:实现URL跳转,隐藏地址,使用perl语言防止注入

2、  如:

http://www.ok1.com/csdn09.php?id=10

转换

http://www.ok1.com/csdn09_10.html

http://www.ok1.com/csdn09_10

3、  配置步骤

Apache主配置httpd.com

1)  启用rewrite模块

2)  启用.htaccess文件

3)  指令格式

将#去掉

#LoadModule rewrite_module modules/mod_rewrite.so

 

#启动重写模块引擎

RewriteEngEine on

#RewriteRule 正则表达式 目标

 

RewriteCond  %{HTTP_HOST}%  !^localhost  [NC]

 

RewriteRule ^/(.*)   http://localhost   [L]

#指定重写规则

RewriteRule ^/test([0-9]*)([a-z]*).html$ /test.php?id=$1   [L]