gpt4 book ai didi

php - 奇怪的行为 - 允许访问 domain.in/file/file

转载 作者:行者123 更新时间:2023-11-28 03:36:20 24 4
gpt4 key购买 nike

我在我的网站上观察到这种奇怪的行为。

我的网络服务器上有以下目录结构

root
login.php
contact.php
myaccount.php
.
.

当我在 url 中输入地址时http://www.domain.in/contact.php 正如预期的那样,我在屏幕上呈现了我的 contact.php。但是当我尝试输入以下地址作为 url 时..http://www.domain.in/contact.php/myaccount.php 我希望下面的事情会发生:

1)  a 404 page to be displayed
2) a redirect to contact.php

但是,页面 myaccount.php 得到呈现,当然不是我希望的样子。

我基本上想是否可以使用 htacess 文件来阻止这种情况,但我无法找出适用于这种情况的任何规则。

我们非常欢迎任何帮助。

最佳答案

忽略我最后的回答,没有完整阅读问题。

尝试将其添加到 myaccount.php 的顶部

 <?php
$host = $_SERVER['HTTP_HOST'];
$self = $_SERVER['PHP_SELF'];
$query = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null;
$url = !empty($query) ? "http://$host$self?$query" : "http://$host$self";
$redirect = '<meta http-equiv="refresh" content="4;url=http://www.domain.in/contact.php">';
if ($url=="http://www.domain.in/contact.php/myaccount.php") echo $redirect;
// The Rest of the page here
?>

关于php - 奇怪的行为 - 允许访问 domain.in/file/file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13984073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com