[英]How to change example.com/index.php/lib to example.com/lib?
I am working with site which was written on Yii 1.1, web server is apache 2. Currently I have to resolve following problem: 我正在使用Yii 1.1编写的站点,Web服务器是apache2。目前,我必须解决以下问题:
There are URLs and each of them presents module. 有URL,每个URL都提供模块。 1) example.com/index.php/library 2) example.com/index.php/sys
1)example.com/index.php/library 2)example.com/index.php/sys
How can i change those URLs to 如何将这些网址更改为
1) example.com/library 2) example.com/sys 1)example.com/library 2)example.com/sys
that is how can i index.php from URL? 那就是我如何从URL index.php?
thanks ! 谢谢 !
It is explained in Yii Framework page in Url Manger 在网址管理器的Yii Framework页面中对此进行了说明
You need to do three things to achieve this in your apache server
. 您需要做三件事才能在
apache server
实现这一目标。
1) Enable url_rewriting
in your apache conf
file 1)在您的
apache conf
文件中启用url_rewriting
2) Use this .htaccess
2)使用此
.htaccess
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
3) config urlmanager in your main.php
3)在您的
main.php
配置urlmanager
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>'),
1)at first include this to setting of virtual host: AllowOverride All
1)首先将其包括到虚拟主机的设置中:
AllowOverride All
2)and add following lines: 2)并添加以下几行:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
3) in config/main.php: 3)在config / main.php中:
urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>**false**
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.