mod_rewrite 规则需要检查...安全吗?

发布于 2024-12-27 05:03:43 字数 345 浏览 1 评论 0原文

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php

这些是我的项目的 .htaccess 文件的代码行。 我只是想问一下是否有任何安全问题或您有什么具体意见 不使用这些线路,而是使用其他线路...

背景:我想使用我自己的小“管理系统”来使我的项目上线 这个系统自己处理每个 uri... 如果在文件系统上找不到特定的 uri 作为目录或文件,它应该重定向到我的 索引文件,因此系统可以显示主页或任何其他页面。

你怎么认为?

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php

these are my code lines for my .htaccess file for an project of mine.
i just want to ask if there're any safety problems or any specific comment of yours
to not use these lines and instead use other lines...

background: i want to use my own little "management system" to get my project online
and this system handle every uri by itself...
if the specific uri not found on the filesystem as a dir or file it should redirect to my
index-file, so the system could instead show home- or any other page.

what do you think?

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

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

发布评论

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

评论(1

前事休说 2025-01-03 05:03:43

我认为你应该使用 ErrorDocument 而不是该行代码。

该行代码意味着如果请求真实目录(存在于服务器上)或现有文件,则不会提供index.php。
因此,如果没有找到文件或目录,页面将被index.php重写,而不是重定向,这意味着用户看到索引页面的内容。

如果您使用 ErrorDocument,用户就知道找不到该文件或目录。

背景:对不起我的英语

I think you should use ErrorDocument instead that lines code.

That lines code mean if request for an real directory ( exists on server) or an exitst file, index.php isn't served.
So if a file or directory is not founded, the page is rewrited by index.php, not redirect, it mean user see content of index page.

if you use ErrorDocument, user know that that file or directory is not found.

background: sorry about my engish

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