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

Cannot redirect to a newly created page in php

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

这是我写的那一行:

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= [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=&%{QUERY_STRING} [L]

任何建议都可以帮助,谢谢。

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