开发者

CakePHP folders in webroot get redirected to app/webroot/folder

开发者 https://www.devze.com 2023-03-07 07:02 出处:网络
In CakePHP you can access files in webroot via domain/file For example the favicon.ico file located at app/webroot/favicon.ico can be accessed from

In CakePHP you can access files in webroot via domain/file

For example the favicon.ico file located at app/webroot/favicon.ico can be accessed from

example.com/favicon.ico

Directories on the other hand seem to have a gotcha.

If I have a directory called blog in the app/webroot/, then as long as I try to access it like:

example.com/blog/

Then it works as expected. However if I try to access it without the trailing slash:

example.com/blog

Then it gets redirected to:

example.com/app/webroot/blog/

This is undesired. I woult rather .com/folder get redirected to .com/folder/ 开发者_如何转开发instead of .com/app/webroot/folder/

Is there a way to set this up?


If you installed wordpress blog and cakephp in document root, you need to replace .htaccess file script with below script:

RewriteEngine on

RewriteCond %{REQUEST_URI} !^/YOUR_WORDPRESS_DIR.*
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^$ app/webroot/ [L]

RewriteCond %{REQUEST_URI} !^/YOUR_WORDPRESS_DIR.*
RewriteCond %{REQUEST_URI} !-d
RewriteRule (.*) app/webroot/$1 [L]


What about using the Router::Connect for blog to redirect directly to the good page? Of course this is not an automatic routine but it mighthelp you.

More info : http://book.cakephp.org/view/945/Routes-Configuration

I suppose there might be a parameter in the config core files, have you already had a look there?


You could try the instructions here

0

精彩评论

暂无评论...
验证码 换一张
取 消