我的登錄重定向是使用絕對url構建的,但我需要使用相對url,因爲我的cakephp應用程序是通過代理服務器提供的。Cake:使用相對URL
路由器類具有這種效果的URL方法的行爲(文檔鏈接: http://api.cakephp.org/class/router#method-Routerurl)
我想我想要做的是設置了「基地」屬性設置爲false,但我不確切地確定如何做到這一點。我只是指定
$this->base = false;
某處? (我試圖在控制器中的beforeFilter中做這件事,但它沒有效果)。
更新:好吧,這不是理想的解決方案,但我可以通過代理服務器將此行添加到paths.php: define('FULL_BASE_URL','http://www.myexternaldomain。 COM「);
然後我還必須在core.php中將安全級別設置爲低。
但後來這意味着,我去訪問該網頁的蛋糕與本地 http://localhostname/cake/users
我會被重定向到這是不是我寧願外部URL。
更新:
這裏是一個的print_r的從我的dev服務器輸出($ _ SERVER):
陣列([REDIRECT_REDIRECT_STATUS] => 200 REDIRECT_STATUS] => 200 HTTP_HOST] => devdataload [HTTP_USER_AGENT] => Mozilla/5.0(X11; U; Linux x86_64; en-US; rv:1.9.2.11)Gecko/20101028 CentOS/3.6-2.el5.centos Firefox/3.6.11 [HTTP_ACCEPT] => text/html,application/xhtml + xml,application/xml; q = 0.9,/; q = 0.8 [HTTP_ACCEPT_LANGUAGE] => en-us,en; q = 0.5 [HTTP_ACCEPT_ENCODING] => gzip,deflate [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8; q = 0.7,*; q = 0.7 [HTTP_KEEP_ALIVE] => 115 [HTTP_CONNECTION] => keep-alive [HTTP_R EFERER] =>http://devdataload/cakepf/users/login [HTTP_COOKIE] => CAKEPHP = ndhjfch0c1oq285ks4d2dfib90; ZDEDebuggerPresent = php,phtml,php3 [PATH] =>/usr/bin:/ bin [SERVER_SIGNATURE] => Apache/2.2.8(CentOS)服務器位於devdataload端口80 [SERVER_SOFTWARE] => Apache/2.2.8 CentOS)[SERVER_NAME] => devdataload [SERVER_ADDR] => 5.213.249.197 [SERVER_PORT] => 80 [REMOTE_ADDR] => 5.213.249.197 [DOCUMENT_ROOT] =>/var/www/html [SERVER_ADMIN] => root @ localhost [ SCRIPT_FILENAME] => /var/www/html/cakepf/app/webroot/index.php [REMOTE_PORT] => 39979 [REDIRECT_QUERY_STRING] => url = alerts [REDIRECT_URL] =>/cakepf/app/webroot/alerts [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => url = alerts [REQUEST_URI] =>/cakepf/alerts [SCRIPT_NAME] =>/cakepf/app/webroot/index。 php [PHP_SELF] => /cakepf/app/webroot/index.php [REQUEST_TIME] => 1299347553
請參閱下面的答案。也許我誤解了這個問題。你有一個具體的例子,你如何生成網址,你得到什麼,你需要什麼? – deceze 2011-02-17 03:48:14