Php Yii 404错误,urlmanager showscript为false
我正在完成我在Yii应用程序上的工作,我希望有更漂亮的URL。我通过谷歌搜索网站和Yii维基,并按照手册进行操作。但是,我无法从URL中隐藏index.php。如果我的url中有index.php,那么网站就会打开,如果没有index.php,它将向我提供服务器404 这是我的main.config:Php Yii 404错误,urlmanager showscript为false,php,apache,.htaccess,mod-rewrite,yii,Php,Apache,.htaccess,Mod Rewrite,Yii,我正在完成我在Yii应用程序上的工作,我希望有更漂亮的URL。我通过谷歌搜索网站和Yii维基,并按照手册进行操作。但是,我无法从URL中隐藏index.php。如果我的url中有index.php,那么网站就会打开,如果没有index.php,它将向我提供服务器404 这是我的main.config: 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array(
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<action>'=>'site/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
我目前正在使用WAMP在本地主机上测试该站点。Apache上的Mod_rewrite正在运行。将http.conf更改为选项索引FollowSymLinks Allow Override All
我还错过了什么?为了那些挣扎的人!将.htaccess放在应用程序的根目录下,而不是放在受保护的文件夹中
'urlManager' => array(
'urlFormat' => 'path',
'urlSuffix' => '.html',
'showScriptName' => false,
// 'caseSensitive'=>false,
'rules' => array(
'<action>'=>'site/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
在项目文件夹中上载您的htaccess 尝试添加:
'' => 'site/index'
到您的urlManager“规则”数组。
逻辑是,Yi无法将模式
''
的请求与您定义的任何规则匹配。在我的情况下,使用相同的设置,会出现以下两种场景:
问题是,最后的“/”符号(需要更多的规则)我知道这是一个古老的答案。但你能解释一下这方面的细节吗?因为这对我来说很有效,但我不知道是什么让它起作用。谢谢你。
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
'' => 'site/index'