2013-02-18 70 views
1

当我们配置YiiBoilerplate。我们使用了它的前端通过这些网址YiiBoilerplate Url Rewriting - php yii

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

我想改变这个网址,并访问它像 http://localhost/YiiBoilerplate-master/site/index. 它是如何可能通过mod_rewrite

+1

此问题与[this one]不匹配(http://stackoverflow.com/questions/1189823/how-to-setup-url-friendly-in-yii-framework-automatically),因为它是使用yii样板具有不同的网址,然后在这个问题中提到的网址。 – Sohail 2013-03-27 08:20:49

+0

https://github.com/clevertech/YiiBoilerplate/issues/33 – Sohail 2013-04-03 13:27:02

回答

1

一个.htaccess文件添加到Web服务器的根:

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

这使您可以通过更短的URL访问您的应用程序,但在应用程序内的链接仍留在更长的形式。为了您的应用程序内更新的URL,在urlManager组件更新baseUrl

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

注:我强烈建议设置一个虚拟主机。

+0

@shmunk这个解决方案根本不起作用。 – Sohail 2013-03-27 08:17:38

+0

你只是想通过这个URL访问它,或者应用程序中创建的所有URL是否也遵循这种格式? – schmunk 2013-03-27 11:33:31