Apache开启rewrite模式
[*]打开Apache配置文件:Apache安装目录/conf/httpd.conf。
[*]搜索rewrite:会找到"#LoadModule rewrite_module modules/mod_rewrite.so",将前面的“#”去掉。
[*]搜索AllowOverride:将所有"AllowOverride none"改成"AllowOverride all"。
[*]确保URL_MODEL设置为2(在项目中的config.php中)
[*]在入口文件目录加入.htaccess文件,文件中写入重写规则。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1
</IfModule
我的PHP项目的入口文件是index.php
最后重启Apache服务器
页:
[1]