PHP 中通过 .htaccess RewriteRule 检测页面是否被调用
我正在我正在开发的网站上使用 .htaccess RewriteRule
。
这是我的 .htaccess 示例,
RewriteEngine on
RewriteRule ^about.htm$ /index.php?load=about&output=html [NC]
我想知道我的 index.php
文件中是否有办法检测 如果该页面已通过重写调用或用户到达该页面 直接地。我试图避免编写一些安全检查 我什至不知道从哪里开始。
如果没有办法进行“检查”,我应该从哪里开始确保安全 文件?
我的猜测是确保只有 load
和 output
传递给 $_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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 $_SERVER 全局中查找 REDIRECT_URL 或 REDIRECT_STATUS。 mod_rewrite 应该添加这些。
Look for REDIRECT_URL or REDIRECT_STATUS in the $_SERVER global. mod_rewrite should be adding these.
您可以检查请求 uri,该 uri 包含在 $_SERVER 全局变量中。
You can check the request uri, which is contained in the $_SERVER global variable.