[英]Change Cakephp routing functionality
當我在重定向下面使用它時,它顯示為xxx.yyy.com/posts/add。
Router::url(
array('controller' => 'posts', 'action' => 'add'),
true
);
當我將最后一個參數更改為false時,它給出了xxx.com/posts/add。
Router::url(
array('controller' => 'posts', 'action' => 'add'),
false
);
以下鏈接形式為xxx.com/posts/add url。
echo $this->Html->link('Add Post', array(
'controller' => 'posts',
'action' => 'new'
));
以下重定向格式為xxx.yyy.com/posts/add url。
$this->redirect(array('controller' => 'posts', 'action' => 'add'));
xxx.yyy.com,這是基本網址。 服務器托管了多個域。 我已經完成了cakephp項目。 我不想更改托管中的任何內容。 我可以在cakephp中進行更改以使其表現為上述代碼以指出xxx.com / ...
這可能嗎?
您可以為此使用CakePHP基本配置 。
Configure::write('App.baseUrl', 'http://example.com');
如果可能,最好使用.htaccess網址重寫:
RewriteCond %{HTTP_HOST} !^example\.com$
RewriteRule ^.*$ http://example.com%{REQUEST_URI} [R=301,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.