Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.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_Header_Include - Fatal编程技术网

无法重定向到php中新创建的页面

无法重定向到php中新创建的页面,php,header,include,Php,Header,Include,您好,我正在尝试重定向到一个php文件,该文件是我在一个现有项目中使用header函数创建的,但它不起作用,结果是404找不到 这是我写的一句话: header('Location:payme.html'); 当我对已经存在的页面执行相同的操作时,例如profile.php如下:header('Location:profile.html') profile.php和payme.php位于同一文件夹中 当我使用include函数时,它工作:include BASE.view/payme.php'

您好,我正在尝试重定向到一个php文件,该文件是我在一个现有项目中使用header函数创建的,但它不起作用,结果是404找不到

这是我写的一句话:

header('Location:payme.html');
当我对已经存在的页面执行相同的操作时,例如profile.php如下:
header('Location:profile.html')

profile.php和payme.php位于同一文件夹中

当我使用include函数时,它工作:
include BASE.view/payme.php'

我认为问题出在.htaccess文件中,可能是有规则阻止了它

以下是.htaccess文件:

<IfModule mod_headers.c>
    Header set Referrer-Policy "same-origin"
    Header always set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
    #Header set Content-Security-Policy "..."
</IfModule>


# -- DEFAULTS --
AddDefaultCharset UTF-8
DefaultLanguage fr

Options -Indexes +FollowSymlinks


# -- DENY ACCESS --
<FilesMatch "^(\.htaccess)$">
order allow,deny
deny from all
</FilesMatch>
<FilesMatch "^(\.htpasswd)$">
order allow,deny
deny from all
</FilesMatch>

# -- ERROR REDIRECTIONS --
ErrorDocument 400 /error400.html
ErrorDocument 403 /error403.html
ErrorDocument 404 /error404.html
ErrorDocument 405 /error405.html
ErrorDocument 500 /error500.html
ErrorDocument 501 /error501.html
ErrorDocument 502 /error502.html
ErrorDocument 503 /error503.html
ErrorDocument 504 /error504.html
ErrorDocument 505 /error505.html

RewriteEngine On



# -- ERROR PAGE ---
RewriteRule ^error([0-9]{3})\.html$ /error.php?code=$1 [L]

# -- FAKE ACCES DENYING ---
RewriteRule ^controller/(.+\.php)?$ /error404.html
#RewriteRule ^cron/(.+)?$ /error404.html
RewriteRule ^datas/(.+)?$ /error404.html
RewriteRule ^email/(.+)?$ /error404.html
RewriteRule ^external/(.+)\.php?$ /error404.html
RewriteRule ^external/php/(.+)$ /error404.html
RewriteRule ^model/(.+\.php)?$ /error404.html
RewriteRule ^params/(.+)?$ /error404.html
RewriteRule ^trustee/(.+\.php)?$ /error404.html
RewriteRule ^view/(.+\.php)?$ /error404.html


# -- SITE PAGES ---
RewriteRule ^(.+)\.html$ /index.php?htaccess_url=$1&%{QUERY_STRING} [L]

标题集引用者策略“相同来源”
标题始终设置X-Content-Type-Options“nosniff”
标题集X-XSS-Protection“1;模式=块”
标头设置严格的传输安全性“最大年龄=31536000;包含子域;预加载”env=HTTPS
#标题集内容安全策略“…”
#--默认值--
AddDefaultCharset UTF-8
默认语言
选项-索引+FollowSymlinks
#--拒绝访问--
命令允许,拒绝
全盘否定
命令允许,拒绝
全盘否定
#--错误重定向--
ErrorDocument 400/error400.html
ErrorDocument 403/error403.html
ErrorDocument 404/error404.html
ErrorDocument 405/error405.html
ErrorDocument 500/error500.html
ErrorDocument 501/error501.html
ErrorDocument 502/error502.html
ErrorDocument 503/error503.html
ErrorDocument 504/error504.html
ErrorDocument 505/error505.html
重新启动发动机
#--错误页---
重写规则^error([0-9]{3})\.html$/error.php?代码=$1[L]
#--假访问否认---
重写规则^controller/(.+\.php)?$/error404.html
#重写规则^cron/(.+)?$/error404.html
重写规则^datas/(.+)?$/error404.html
重写规则^email/(.+)?$/error404.html
重写规则^external/(.+)\.php?$/error404.html
重写规则^external/php/(.+)$/error404.html
重写规则^model/(.+\.php)?$/error404.html
重写规则^params/(.+)?$/error404.html
重写规则^truster/(.+\.php)?$/error404.html
重写规则^view/(.+\.php)?$/error404.html
#--网站页面---
重写规则^(+)\.html$/index.php?htaccess\u url=$1&%{QUERY\u STRING}[L]

任何建议都会有所帮助,谢谢。

通过在主控制器文件index.php中添加所创建页面的名称,问题得以解决。

从您尝试重定向的页面到payme.html的路径是什么?这是Location指令中必须使用的路径。它是payme.php还是payme.html?路径是Base。'view/payme.php“这是一个包含html代码的php文件,您必须从外部用户的角度指定位置。首先要确保这是有效的<代码>http://yourdomain/view/payme.php
。或
http://yourdomain/???/payme.php
。代替使用payme.php的路径。然后使用完全相同的路径指定您的位置。