Csuper Blog

Csuper Blog

Apache 利用 URL Rewrite 静态化地址(.htaccess)
2011-03-04

以下我们说明一下如何让APACHE服务器支持".htAccess",同时举例说明如何利用 URL Rewrite把动态地址转化为静态地址。

1、 修改文件:Apache2.X.X\conf\httpd.conf
找到

LoadModule rewrite_module modules/mod_rewrite.so




将前面的#删除
2、 查找所有的AllowOverride,将后面的none修改为ALL

<Directory />    Options FollowSymLinks    AllowOverride ALL


//就是这一行    Order deny,allow    Allow from all    Satisfy all </Directory>
3、 重新启动Apache
4、 再配上针对于你的程序设计的.htaccess文件,就可以静态化网页。
5、 .htaccess配置文件使用如下:

 

# 将RewriteEngine 模式打开RewriteEngine On


# Rewrite 系统规则RewriteRule ^index\.html$ index1.php



说明:上面的代码就是让网站的index1.php的地址改写为index.html
index1.php文件范例如下。

   1. <?php     2.        phpinfo();     3. ?>  

发表评论: