我有一个需求,我需要重定向
domain.com/index.php, www.domain.com/index.php & www.domain.com/index/ to www.domain.com
我的应用程序没有使用。htaccess文件。
我想没有。htaccess文件没有解决方案,所以构建一个
在您的yii配置中设置main.php,在component:
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
),
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule rewrite_module modules/mod_rewrite.so
然后进入。htaccess文件,并尝试修改为:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)'?*$ index.php/$1 [L,QSA]
如果上面的不工作,试试这个:
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
移动。htaccess文件到根目录,index.php所在目录
www——保护- - - - - - index . php- . htaccess
重启服务器,一切正常