Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
yii urlManager:如果隐藏index.php,则停止工作规则_Php_Yii - Fatal编程技术网

yii urlManager:如果隐藏index.php,则停止工作规则

yii urlManager:如果隐藏index.php,则停止工作规则,php,yii,Php,Yii,如果我在URL中隐藏(通过.htaccess或php代码重定向)index.php name脚本,则规则将停止工作(404 error) 这意味着它在开始时工作,但现在不工作。 我能做什么 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array( 'test'=>'site/index', ), 我补充说: R

如果我在URL中隐藏(通过.htaccess或php代码重定向)index.php name脚本,则规则将停止工作(404 error)

这意味着它在开始时工作,但现在不工作。
我能做什么

'urlManager'=>array(
    'urlFormat'=>'path',
    'showScriptName'=>false,
    'rules'=>array(
        'test'=>'site/index',
    ),
我补充说:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

一切正常,但现在我的404规则不起作用了…

(ErrorDocument  404     /404.html)

回答
如果您不想要dinamic 404页面(yii站点中的默认值/错误),请将其更改为:

RewriteRule . index.php

RewriteRule .* /404.html

您在main.php中创建的路由规则工作正常,但您没有告诉apache超越.htaccess中的重定向规则。如果您使用的是linux,请在
/etc/apache2/sites available/

<Directory "/baepath/to/application">
AllowOverride All
#...
</Directory>

允许超越所有
#...

或者更常见的是,您可以通过为项目创建新的目录规则来创建虚拟环境

这可能有助于您在中共享重定向规则。htaccessnow my 404规则不起作用