【发布时间】:2014-05-13 09:30:44
【问题描述】:
我在 Yii 中无法配置路由项目是 3 天,所有尝试帮助... 我有:
/var/www/ - 项目
/var/www/yii - yii 框架
./htaccess
RewriteEngine On
# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is http://localhost/begin/, use /begin/
RewriteBase /
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
index.php 找到。
./var/www/protected/config/main.php
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false,
'rules'=>array(
'/'=>'/view',
'//'=>'/',
'/'=>'/',
),
),
当我输入例如 107.170.91.28/site/contact 时,会显示错误 404。 服务器地址 107.170.91.28 在本地服务器上。一切正常。 如果我输入此 URL 107.170.91.28/index.php/site/contact 或 107.170.91.28/index.php?r=site/contact - 它可以工作。 寻求帮助,因为我尝试了所有设置的方法。
【问题讨论】:
-
将 .htaccess 放在 index.php 所在的位置
-
你为什么改变你的url规则?
-
/var/www/.htaccess 与 /var/www/index.php 在同一文件夹中
-
我试过了,但我没有正确配置。在本地服务器上有这样的规则,一切正常。
标签: php .htaccess yii yii-url-manager