PHP 中通过 .htaccess RewriteRule 检测页面是否被调用

发布于 2024-09-25 03:07:18 字数 512 浏览 0 评论 0原文

我正在我正在开发的网站上使用 .htaccess RewriteRule

这是我的 .htaccess 示例,

RewriteEngine on
RewriteRule ^about.htm$ /index.php?load=about&output=html [NC]

我想知道我的 index.php 文件中是否有办法检测 如果该页面已通过重写调用或用户到达该页面 直接地。我试图避免编写一些安全检查 我什至不知道从哪里开始。

如果没有办法进行“检查”,我应该从哪里开始确保安全 文件?

我的猜测是确保只有 loadoutput 传递给 $_GET,创建 strip_tags()trim()stripslashes() 并删除引号。

谢谢你!

I am using .htaccess RewriteRule on a website I'm working on.

Here is a sample of my .htaccess

RewriteEngine on
RewriteRule ^about.htm$ /index.php?load=about&output=html [NC]

I would like to know if there is a way in my index.php file to detect
if the page have been called via a Rewrite or the user reached it
directly. I'm trying to avoid having to write some security check that
I am not even sure where to start.

If there is no way to make that "check" where should I start to secure
the file ?

My guess would be to make sure only load and output are
passed to the $_GET, make a strip_tags(), trim(), stripslashes() and remove quotes.

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何以畏孤独 2024-10-02 03:07:18

在 $_SERVER 全局中查找 REDIRECT_URL 或 REDIRECT_STATUS。 mod_rewrite 应该添加这些。

Look for REDIRECT_URL or REDIRECT_STATUS in the $_SERVER global. mod_rewrite should be adding these.

鸠书 2024-10-02 03:07:18

您可以检查请求 uri,该 uri 包含在 $_SERVER 全局变量中。

You can check the request uri, which is contained in the $_SERVER global variable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文