cakephp部署在sae上遇到的跳转问题
sae cakephp 跳转
在sae上部署了cakephp,结果我连基础的跳转都没搞定,真心失败啊。只好来这里求教了。我在本地实验了一下相同的代码,是好用的,但是部署到sae上就不行了。代码片段如下
AppController.php:
AppController extends Controller { public function beforeFilter() { parent::beforeFilter(); $current_ctl = strtolower($this->name); if($current_ctl === 'pages'){ //在这里echo的打断点的话,sae里面也可以正常显示 $this->redirect(array('controller' => 'test', 'action' => 'index')); } }}
TestController.php:
class TestController extends AppController { var $name = 'test'; var $uses = Array(''); public function index() { /*这里echo打断点已经没用了,初步怀疑是大小写问题,但是我实验过了很多中,比如文件名带下划线,不带下划线,首字母大写,小写。name名改成Test,以及声明name用public的都无效*/ $this->set('CN', '中文测试'); }}
index.ctp:
<h2><?php echo $CN; ?></h2>
在本机上正常显示,但是sae上就一片空白。不知道为什么。真心奇怪啊。
回复讨论(解决方案)
你这个框架要写盘的吗?如果要就不能用的
我明白你的意思,因为默认的cakephp是要写app的tmp文件的,但是sae不支持写文件的,所以如果什么不改就移植的话,会出现问题。我移植了一个版本,将cake要写的文件都写在了Memcache里面了。因此可以跑通。
我已经将代码上传到了github上了
https://github.com/jianghu52/sae_cakephp_sample。这个包如果直接上传到sae上就可以打开home页面。但是问题就是。我没有办法实现跳转
我在pagecontroller里写了一句跳转方法【$this->redirect(array('controller' => 'test', 'action' => 'index'));】。在sae上的表现形式是地址栏可以显示【http://**.sinaapp.com/test】。页面报错为【The requested URL /test was not found on this server.】。也就是说我写的controller没有被解析。不知道问题出在哪里。
研究了半天,终于搞明白一件事。就是我对sae本身的文件系统不够了解。
给的原来的框架里面,只有sae_app_wizard.xml,而不存在config.yaml文件,因此,redirect的跳转依然是向app里的tmp包请求内容,不能成功。添加了config.yaml文件,在里面加这样两句
handle: - rewrite:if (!is_file() && !is_dir() && path ~ "^app/webroot/(.*)") goto "app/webroot/index.php?url=$1&%{QUERY_STRING}" - rewrite:if (!is_file() && !is_dir() && path ~ "(.*)") goto "app/webroot/$1?%{QUERY_STRING}"
就可以实现跳转了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Laravel simplifies HTTP verb handling in incoming requests, streamlining diverse operation management within your applications. The method() and isMethod() methods efficiently identify and validate request types. This feature is crucial for building

The Storage::download method of the Laravel framework provides a concise API for safely handling file downloads while managing abstractions of file storage. Here is an example of using Storage::download() in the example controller:
