前言:phpstudy在apache模式下重写url
1.打开httpd.conf配置文件,ctrl+F 找到:mod_rewrite.so ,去掉前面的#号。
确认是否加载rewrite模块:
通过phpinfor()函数即可查看。
2.查找 FollowSymLinks
Options FollowSymLinks
AllowOverride None
改为
Options FollowSymLinks
AllowOverride All
注意一定要是Options FollowSymLinks 元素里的,其他元素修改为all均无效
3.把下面的内容保存为.htaccess文件放到入口文件的同级目录下
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
4.重启Apache重新访问