Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 启用修改脚本(谷歌应用程序引擎)_Php_Regex_.htaccess_Google App Engine_Mod Rewrite - Fatal编程技术网

Php 启用修改脚本(谷歌应用程序引擎)

Php 启用修改脚本(谷歌应用程序引擎),php,regex,.htaccess,google-app-engine,mod-rewrite,Php,Regex,.htaccess,Google App Engine,Mod Rewrite,嘿,伙计们,如果这个问题以前有人回答过,我很抱歉,但我找不到答案。我有一个.htaccess,启用了RewriteEngine,其中有一条规则: RewriteEngine on RewriteRule ^(.*) public/$1 [L] 我想在mod_rewrite.php中解释这个规则,它在我的app.yaml的处理程序中调用 mod_rewrite.php: <?php /** * @file * Provide basic mod_rewrite like f

嘿,伙计们,如果这个问题以前有人回答过,我很抱歉,但我找不到答案。我有一个.htaccess,启用了RewriteEngine,其中有一条规则:

  RewriteEngine on
  RewriteRule ^(.*) public/$1 [L]
我想在mod_rewrite.php中解释这个规则,它在我的app.yaml的处理程序中调用

mod_rewrite.php:

 <?php
 /**
 * @file
 * Provide basic mod_rewrite like functionality.
 *
 * Pass through requests for root php files and forward all other requests to
 * index.php with $_GET['q'] equal to path. The following are examples that
 * demonstrate how a request using mod_rewrite.php will appear to a PHP script.
 *
 * - /install.php: install.php
 * - /update.php?op=info: update.php?op=info
 * - /foo/bar: index.php?q=/foo/bar
 * - /: index.php?q=/
 */

 $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

 // Provide mod_rewrite like functionality. If a php file in the root directory
 // is explicitly requested then load the file, otherwise load index.php and
 // set get variable 'q' to $_SERVER['REQUEST_URI'].
 if (dirname($path) == '/' && pathinfo($path, PATHINFO_EXTENSION) == 'php') {
 $file = pathinfo($path, PATHINFO_BASENAME);
 }
 else {
 $file = 'index.php';

 // Provide mod_rewrite like functionality by using the path which excludes
 // any other part of the request query (ie. ignores ?foo=bar).
 $_GET['q'] = $path;
 }

// Override the script name to simulate the behavior without mod_rewrite.php.
// Ensure that $_SERVER['SCRIPT_NAME'] always begins with a / to be consistent
// with HTTP request and the value that is normally provided.
$_SERVER['SCRIPT_NAME'] = '/' . $file;
require $file; 

我可能完全错了,但不会

$path = 'public'.parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
够了吗

另外,更改

$file = 'index.php';


*如果index.php位于公用文件夹中,则忽略最后一点。

当我离开顶行时,会看到一个空白页面。但是,当我按照您的建议执行
public/index.php
时,我得到一个错误
警告:require(../vendor/autoload.php):无法打开流:
,同时出现一个致命错误。这意味着它只找到该脚本,而不调用所有其他脚本,如
autoload.php
尝试将mod_重写拖到公共文件夹中,并在.yaml文件中将“script:mod_rewrite.php”更改为“script:public/mod_rewrite.php”,这很好,但仅适用于主页。它开始工作,但是当我点击导航时,所有其他URL都不工作。当你点击其他链接时会发生什么?它是返回主页还是给出错误?链接指向的URL是什么?浏览器中的URL会更改,但页面保持不变。我使用laravel和composer,我的目录结构是基于MVC的。e、 g.视图位于
application/view/example_script.php
,模态位于
application/modal/example_script.php
中,控制器位于
application/controller/example_script.php
$file = 'public/index.php';