yii框架中的url友好型不起作用
我正在使用Ubuntu12.04,并在yii框架中为url友好工作,我遵循以下步骤:yii框架中的url友好型不起作用,yii,Yii,我正在使用Ubuntu12.04,并在yii框架中为url友好工作,我遵循以下步骤: 步骤1。通过终端打开重写加载模块 -sudo a2enmod rewrite -sudo /etc/init.d/apache2 restart 在apache中加载的模块: core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod
步骤1。通过终端打开重写加载模块
-sudo a2enmod rewrite
-sudo /etc/init.d/apache2 restart
在apache中加载的模块:
core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic
mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user
mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5
mod_reqtimeout mod_rewrite mod_setenvif mod_status
第2步:创建.htaccess并复制到项目中
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>
项目新闻和控制器新闻
非常感谢您的.htaccess需要放在index.php所在的文件夹中,服务器的文档根也需要指向该文件夹。您应该首先尝试一下/news/index.php?r=news/index独立工作 您是否尝试过URL/news/index.html?如果它应该是/news/news/您可能需要在您的.htaccess文件中重新设置为/news/这可能有助于您的Url不能在本地主机上运行?也许我将设置新的运行环境
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false,
'urlSuffix'=>'.html',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
Not Found
The requested URL /news/news/index.html was not found on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80