PHP伪静态Rewrite设置之APACHE篇

网络编程 发布日期:2025/6/26 浏览次数:1

正在浏览:PHP伪静态Rewrite设置之APACHE篇

 一、Apache配置:
 
1、支持httpd.conf 配置
2、支持目录 .htaccess配置(一种"分布式配置"文件针对虚拟空间,空间商不让修改Apache配置文件)
 
启用Rewrite(httpd.conf)
(有时候Options Indexes FollowSymLinks会出问题,只需要配置Options all即可)

LoadModule rewrite_module modules/mod_rewrite.so

 
启用.htaccess
AllowOverride None    修改为:AllowOverride All
 
二、mod_rewrite 规则:
例如:

RewriteEngine on              ->启动rewrite引擎
 
RewriteRule ^/test([0-9]*).html$ /test.php"htmlcode">
RewriteRule ^/new([0-9]*)/$ /new.php"htmlcode">
RewriteEngine on
RewriteRule ^/in(.*).html$ /index.php