请按照以下步骤从Yii中的URL中删除index.php。
第一步:打开文件protected/config/main.php并设置以下设置并保存。
'urlManager' => array(
'showScriptName' => false,
步骤2的.htaccess的变化:
Options -Multiviews
Options +FollowSymLinks
RewriteEngine on
RewriteBase/
# 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如果不工作,然后用下面的步骤启用它。
首先使用此命令使改写:
$ sudo a2enmod rewrite
然后重新启动的Apache2:
$ sudo service apache2 restart
然后进入网站可用文件夹:
$ cd /etc/apache2/sites-available
编辑该文件名为默认并将AllowOverride none更改为AllowOverride All。有两条线需要进行这种改变。 这将使.htaccess在你的服务器上工作。
打开并编辑从该文件VIM /etc/apache2/sites-available/000-default.conf
<Directory /var/www/html/>
AllowOverride all
Options None
Require all granted
</Directory>
最后重新启动的Apache2服务以应用所有更改
$ sudo service apache2 restart
你重写转换规则从Apache到Nginx? http://stackoverflow.com/questions/14927184/converting-htaccess-to-nginx-mod-rewrite – SiZE
@SiZE是的,我试过'位置/ { try_files $ uri $ uri//index.php?args; }' 默认演示博客工作正常,但我的应用程序没有。 在Apache中我有'RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d RewriteRule ^(。*)\?* $ index.php/$ 1 [L,QSA]' –
也许这个wiki会帮助http://www.yiiframework.com/wiki/15/ – SiZE