htaccess的不工作我的欲望使用CakePHP [英] .htaccess is not working by my desires with CakePHP

查看:222
本文介绍了htaccess的不工作我的欲望使用CakePHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有/本地主机/域/本地主机/ myCakephpApp Web服务器上。我不能做的文件夹结构什么,但我可以在/本地主机/,现在简化看起来像这样修改的.htaccess:

There is /localhost/domains/localhost/myCakephpApp on web server. I can't do anything with folder structure, but I can edit .htaccess in /localhost/, which now simplified looks like this:

RewriteRule (.*) /domains/localhost/$1 [L]

我在本地主机的网站/域/本地主机/ myCakephpApp拥有标准蛋糕.htaccess文件:

My website in localhost/domains/localhost/myCakephpApp has standard cake .htaccess file:

RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]

我很高兴,的http://本地主机/不管/ 的作品,但在CakePHP的各个环节(含做HTML助手)都指向的http://本地主机/域/本地主机/不管/ ,它可以访问。

It is nice that http://localhost/whatever/ works, but all links in cakephp (done with html helper) are pointing to http://localhost/domains/localhost/whatever/ and it is accessible.

我应该怎么做才能让只在的http://本地主机/ 并没有对的 HTTP://本地主机/域/本地主机/

What should I do to make the website running only on http://localhost/ and not on http://localhost/domains/localhost/?

编辑:

好吧,我在根修改的.htaccess(HTTP://本地主机/):

Okay, I have modified the .htaccess in root (http://localhost/):

RewriteRule ^$ /domains/localhost/app/webroot/ [L]
RewriteRule (.*) /domains/localhost/app/webroot/$1 [L]

和删除的一个在的http://本地主机/结构域/本地主机/ 的,这意味着在网络仅//本地主机,但链接还指向的 HTTP访问//本地主机/域/本地主机/无论相对=nofollow>的http://本地主机/域/本地主机/不管(E404)

and deleted one in http://localhost/domains/localhost/ which means that the web is only accessible from http://localhost, but links are still pointing at http://localhost/domains/localhost/whatever (e404)

有什么在蛋糕的路由,如基本URL?我寻觅了很多,但毫无效果。

Is there something in cake's routing like "base url"? I have searched a lot, but nothing worked.

推荐答案

问题在于CakePHP中使用原始URI从服务器解析的动作,而不是重写一个!

The problem is that CakePHP uses the original uri from the server to resolve the action, not the rewritten one!

尝试在bootstrap.php中这种黑客:

Try this "hack" in bootstrap.php:

Configure::write('App.base', '/');
$_SERVER['REQUEST_URI'] = preg_replace('|/domains/localhost|', '', $_SERVER['REQUEST_URI']);

这篇关于htaccess的不工作我的欲望使用CakePHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆