简体   繁体   English

如何将example.com/index.php/lib更改为example.com/lib?

[英]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.

相关问题 将example.com/dashboard.php更改为example.com/index.php?action=dashboard - Change example.com/dashboard.php to example.com/index.php?action=dashboard 如何将example.com/forum/index.php重定向到example.com/forum/ - How to redirect example.com/forum/index.php to example.com/forum/ 如何从这个example.com/index.php?lang=en更改我的多语言网址到这个example.com/en/? - How can I change my multilingual urls from this example.com/index.php?lang=en to this example.com/en/? Ubuntu-如何直接将example.com/opencart/index.php定向到http://example.com/和www.example.com? - Ubuntu - How direct example.com/opencart/index.php to http://example.com/ and www.example.com? 使用,htaccess将example.com?id=12重定向到example.com/index.php?id=12 - using ,htaccess redirect example.com?id=12 to example.com/index.php?id=12 是否可以将 example.com/index.php?page=abc 重定向到 example.com/abc? - Is it possible to redirect the example.com/index.php?page=abc to example.com/abc? 如何使用.htaccess将http://example.com/test.php设置为http://example.com/index.php?do=test? - How to make http://example.com/test.php to http://example.com/index.php?do=test using .htaccess? “ example.com/index.php/page/about/”是好的做法吗? - Is “example.com/index.php/page/about/” good practice? 如何将example.com/index.php#anchor的URL重写为example.com/anchor? - How do I rewrite the URL for example.com/index.php#anchor to example.com/anchor? 如何使用example.com/index.php?ref=origin跟踪用户来源PHP - How to track users origin PHP by using example.com/index.php?ref=origin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM