Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.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::将www.domain.com/index.php重定向到www.domain.com,而不使用htaccess_Php_Yii_Url Routing - Fatal编程技术网

Yii::将www.domain.com/index.php重定向到www.domain.com,而不使用htaccess

Yii::将www.domain.com/index.php重定向到www.domain.com,而不使用htaccess,php,yii,url-routing,Php,Yii,Url Routing,我有一个需要重定向的要求 domain.com/index.php, www.domain.com/index.php & www.domain.com/index/ to www.domain.com 我的应用程序未使用.htaccess文件。它只能用php完成。我想没有没有.htaccess文件就没有解决方案,所以构建一个 在yii配置中的组件处设置main.php: 'urlManager'=>array( 'urlFormat'=>'path', '

我有一个需要重定向的要求

domain.com/index.php, www.domain.com/index.php & www.domain.com/index/ to www.domain.com

我的应用程序未使用.htaccess文件。它只能用php完成。

我想没有没有.htaccess文件就没有解决方案,所以构建一个

在yii配置中的组件处设置main.php:

'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

万维网 -保护 -index.php -.htaccess


重新启动服务器,然后一切都会正常运行

你尝试了什么?你尝试了yii中的一些代码吗?我尝试过分解url,如果有“索引”将其删除。但是,这似乎不可行。如果我找不到任何解决方案,这将是我最后的选择:(尝试阅读此链接,你可能会得到一些解决方案。)