我是新来的Yii和面临的URL的一些问题。我不想的index.php
在我的网址。下面code我尝试过:
的.htaccess
文件:
RewriteEngine叙述上
#如果一个目录或文件是否存在,直接使用它
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
#否则将其转发到index.php
重写规则。的index.php
我加在我的 main.php
文件如下:
'urlManager'=>阵列(
urlFormat'=>'路',
CASESENSITIVE'=>假的,
),
如果我手动删除index.php的是OK。 BT如果我点击菜单链接它去
< DIV ID =MainMenu的>
< PHP $这个 - >插件('zii.widgets.CMenu',阵列(
'项目'=>阵列(
阵列(标签=>'家','URL'=>阵列(后/索引)),
阵列(标签=>关于,URL =>阵列(网站/网页','查看'=>关于)),
阵列(标签=>'联系','URL'=>阵列('网站/联系')),
阵列(标签=>登录,URL =>阵列('网站/登录),可见'=>的Yii ::应用程序() - >用户自> isGuest)
阵列(标签=>退出(.Yii ::应用程序() - >用户自>名称')','URL'=>阵列('网站/注销),看得见 !=>的Yii ::应用程序() - >用户自> isGuest)
),
)); ?>
解决方案
我认为错误是,请先取消注释
的LoadModule rewrite_module模块/ mod_rewrite.so
点击此处查看更多信息警予的http:// thewayofcoding .COM / 2009/11 /清洁网址功能于PHP-警予骨架/
I am new to yii and facing some issues with the url. I don't want index.php
in my url. I've tried following code:
.htaccess
file:
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
I have added following in my main.php
file:
'urlManager'=>array(
'urlFormat'=>'path',
'caseSensitive'=>false,
),
if i remove index.php manually it is ok . bt if i click on menu link it goes to
<div id="mainmenu">
<?php $this->widget('zii.widgets.CMenu',array(
'items'=>array(
array('label'=>'Home', 'url'=>array('post/index')),
array('label'=>'About', 'url'=>array('site/page', 'view'=>'about')),
array('label'=>'Contact', 'url'=>array('site/contact')),
array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('site/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
)); ?>
解决方案
I think the error is for ,please uncomment it first
LoadModule rewrite_module modules/mod_rewrite.so
Check here for more info yii http://thewayofcoding.com/2009/11/clean-urls-in-php-yii-framework/