ThinkPHP在SAE上关于url重写的有关问题

WBOY
Release: 2016-06-13 13:00:03
Original
769 people have browsed it

ThinkPHP在SAE下关于url重写的问题
thinkphp。
根目录下有config.yaml(因为SAE不支持.htaccess)
内容为:

name: thinktest
version: 1
handle:
  - rewrite: if(!is_dir() && !is_file() && path~"^(.*)$") goto "/index.php/$1"
  - rewrite: if(path~"^/test\.html$") goto "/test.php"

关键看第二个重写。
在根目录下有test.html和test.php
访问test.html的时候可以访问到test.php

问题是
有入口文件index.php
Action里有文件IndexAction.class.php
其中index操作代码如下:

  echo "<script>";<br />   echo " location='".APP_PATH."Tpl/default/Index/test.html';";<br />   echo "</script>";

即页面跳转。
同时在Tpl/default/Index/下有test.html和test.php
此时跳转后不会访问到test.php

不过如果是跳转到根目录下的test.html的话就没问题。

是不是跟config.yaml的作用范围有关?还是有其他原因?

求高手解答!
------解决方案--------------------
thinkphp 的伪静态是通过 PATH_INFO 实现的
唯一可能需要使用 url 重写的是: 隐藏 index.php 文件名

thinkphp 是单一入口的,所以不会出现 http://serverName/test.php 这样的 url

这一点无论是从
.htaccess 的
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
还是config.yaml的
- rewrite: if(!is_dir() && !is_file() && path~"^(.*)$") goto "index.php/$1"
都可以看出:他将域名外的所有内容都转换成了index.php的参数

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!