YII 下url 美化
1、 在components下添加如下配置:
'urlManager'=>[
'enablePrettyUrl' => true,
'showScriptName' => false,//index.php
],
2、 如果服务器是apache,确保apache开启rewrite模块 在apache conf文件中搜索mod_rewrite,去掉前面的『#』
LoadModule rewrite_module modules/mod_rewrite.so
3、在web目录下新建文件.htaccess文件。内容如下:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>