本文介绍了YiiBoilerplate网址重写-PHP yii的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们配置YiiBoilerplate时.我们通过这些网址使用其前端

When we configure YiiBoilerplate. we use its frontend by these url

http://localhost/YiiBoilerplate-master/frontend/www/index.php/site/

我想更改此URL并像访问它一样http://localhost/YiiBoilerplate-master/site/index.mod_rewrite怎么可能?

i want to change this url and access it likehttp://localhost/YiiBoilerplate-master/site/index.how it is possible by mod_rewrite?

推荐答案

.htaccess文件添加到您的Web服务器根目录:

Add a .htaccess file to your webserver root:

RewriteEngine on
RewriteRule ^/YiiBoilerplate-master/(.*) /YiiBoilerplate-master/frontend/www/index.php/$1

这使您可以通过较短的URL访问应用程序,但应用程序内的链接仍保留较长的形式.要更新应用程序中的URL,请更新urlManager组件中的baseUrl:

This gives you access to your app via a shorter URL, but the links within the app still stay in the longer form. To update the URLs within your app, update baseUrl in the urlManager component:

'components' =>
    'urlManager' => array(
        'baseUrl' => '/YiiBoilerplate-master',
        'urlFormat' => 'path',
        ...

注意:我强烈建议您设置虚拟主机.

这篇关于YiiBoilerplate网址重写-PHP yii的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 09:03