route-cakephp Controller URL Modification

Source: Internet
Author: User
A small project was recently developed with CakePHP. Found a problem, the web search materials temporarily did not find a solution, want to ask you Daniel.

CakePHP is placed in the/animal/folder in the root directory of the Web site, all URLs are
http://sample.com/animal/:controller/...

You want to take the contents of one of the controllers to the top level directory, such as changing the controller named Dog to
http://sample.com/animal/dog/...
http://sample.com/dog/...

The current practice is to modify the. htaccess file under the root directory

Options +FollowSymLinksRewriteEngine onRewriteCond %{REQUEST_URI} !/$RewriteCond %{REQUEST_URI} !\.[^/\.]+$RewriteRule .* %{REQUEST_URI}/ [L,R]RewriteRule ^dog/(.*)/ animal/dog [L]RewriteRule ^dog/(.*) animal/dog [L]

But there is a problem, the link in HtmlHelper in view is still/animal/,
Paginator is also automatically added with/animal/

echo $this->Html->link(    'Dog',    array('controller' => 'dog', 'action' => 'smile'));URL: http://sample.com/animal/dog/smile

How do I modify this type of problem in cakephp configuration? Without affecting the links of other controllers?

Thanks Thank you!!

Reply content:

A small project was recently developed with CakePHP. Found a problem, the web search materials temporarily did not find a solution, want to ask you Daniel.

CakePHP is placed in the/animal/folder in the root directory of the Web site, all URLs are
http://sample.com/animal/:controller/...

You want to take the contents of one of the controllers to the top level directory, such as changing the controller named Dog to
http://sample.com/animal/dog/...
http://sample.com/dog/...

The current practice is to modify the. htaccess file under the root directory

Options +FollowSymLinksRewriteEngine onRewriteCond %{REQUEST_URI} !/$RewriteCond %{REQUEST_URI} !\.[^/\.]+$RewriteRule .* %{REQUEST_URI}/ [L,R]RewriteRule ^dog/(.*)/ animal/dog [L]RewriteRule ^dog/(.*) animal/dog [L]

But there is a problem, the link in HtmlHelper in view is still/animal/,
Paginator is also automatically added with/animal/

echo $this->Html->link(    'Dog',    array('controller' => 'dog', 'action' => 'smile'));URL: http://sample.com/animal/dog/smile

How do I modify this type of problem in cakephp configuration? Without affecting the links of other controllers?

Thanks Thank you!!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.