当我们配置YiiBoilerplate。我们使用了它的前端通过这些网址YiiBoilerplate Url Rewriting - php yii
http://localhost/YiiBoilerplate-master/frontend/www/index.php/site/
我想改变这个网址,并访问它像 http://localhost/YiiBoilerplate-master/site/index.
它是如何可能通过mod_rewrite
?
当我们配置YiiBoilerplate。我们使用了它的前端通过这些网址YiiBoilerplate Url Rewriting - php yii
http://localhost/YiiBoilerplate-master/frontend/www/index.php/site/
我想改变这个网址,并访问它像 http://localhost/YiiBoilerplate-master/site/index.
它是如何可能通过mod_rewrite
?
一个.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',
...
注:我强烈建议设置一个虚拟主机。
此问题与[this one]不匹配(http://stackoverflow.com/questions/1189823/how-to-setup-url-friendly-in-yii-framework-automatically),因为它是使用yii样板具有不同的网址,然后在这个问题中提到的网址。 – Sohail 2013-03-27 08:20:49
https://github.com/clevertech/YiiBoilerplate/issues/33 – Sohail 2013-04-03 13:27:02