Route-cakephpcontrollerURL modification

Source: Internet
Author: User
I recently used cakephp to develop small projects. I found a problem. I have not found a solution for searching materials on the internet. I would like to ask you about it. Cakephp is placed in the animal folder under the root directory of the website. all URLs are sample. comanimal: controller... I want to develop small projects using cakephp recently. I found a problem. I have not found a solution for searching materials on the internet. I would like to ask you about it.

Cakephp is placed in the/animal/folder under the root directory of the website. all URLs are
Http://sample.com/animal/:controller...

To get the content of a controller to the directory at the upper level, for example, change the controller named dog
Http://sample.com/animal/dog...
Http://sample.com/dog...

The current practice is to modify the. htaccess file in 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]

However, the link in HtmlHelper in the view still has/animal /,
Paginator is automatically added with/animal/

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

How can I modify this type of problem in cakephp configuration? Does it affect the connections of other controllers at the same time?

Thank you !!

Reply content:

I recently used cakephp to develop small projects. I found a problem. I have not found a solution for searching materials on the internet. I would like to ask you about it.

Cakephp is placed in the/animal/folder under the root directory of the website. all URLs are
Http://sample.com/animal/:controller...

To get the content of a controller to the directory at the upper level, for example, change the controller named dog
Http://sample.com/animal/dog...
Http://sample.com/dog...

The current practice is to modify the. htaccess file in 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]

However, the link in HtmlHelper in the view still has/animal /,
Paginator is automatically added with/animal/

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

How can I modify this type of problem in cakephp configuration? Does it affect the connections of other controllers at the same time?

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.