在 svn/git 存储库中使用 .htaccess 文件有一个主要缺点吗?

发布于 2024-09-02 02:37:07 字数 253 浏览 1 评论 0原文

如果我们的 .htaccess 文件纯粹用于 mod 重写,那么将 .htaccess 文件与存储库中的其他文件一起提交是否存在安全/开发方面的缺点?

由于各种原因(我们的 SEO 优化器喜欢在新促销活动发生时添加漂亮的网址等),我们需要在这些文件中添加一些重写规则。我最好将路由推入 php-land 并在那里处理它吗?或者通过 apache 从 .htaccess 读取可以吗?

.htaccess 文件不会通过 Web 服务器公开,因此不存在安全风险。

If our .htaccess files are purely for mod rewrites, is there a security / development downside to committing .htaccess files alongside other files in your repository?

For various reasons (our SEO optimisers like to add pretty urls as new promotions occur, etc) we need a fair few rewrite rules inside these files. Would I be better off pushing the routing into php-land and dealing with it there? Or is reading from a .htaccess via apache fine?

The .htaccess files are not exposed via the web server, so that's not a security risk.

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

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

发布评论

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

评论(2

少钕鈤記 2024-09-09 02:37:07

我记得,一旦你使用了一个 .htaccess 文件,你就已经同意支付价格,这个价格是 apache 会在每个请求中到处寻找 .htaccess 文件。但这是一个性能问题。

我认为您理想的解决方案是根本不使用 .htaccess 文件,而是在 httpd.conf 中设置这些规则。 PHP 在重定向方面并不比 apache 更好,所以没有帮助。这就是性能的答案。开发感觉最好,然后在生产中将规则移至服务器核心。

至于版本控制,如果它是一个充满文本的文件,这是代码所需要的,那么是的,我会将其放入版本控制中。事实上我现在就这么做。如果许多人在各处的 .htaccess 文件中添加自己的重定向规则,您将希望能够:

  1. 回滚更改。
  2. 指点一下! ;)

As I recall, once you use one .htaccess file, you already have agreed to pay the price, that price being apache will look all over the place, every request, for .htaccess files. That's a performance issue though.

I think your ideal solution is to not use .htaccess files at all, but set those rules in httpd.conf. PHP is not better at redirection than apache, so no help there. That's the performance answer. Develop however feels best, and then for production move the rules into the server core.

As for version control, if it is a file full of text, that is needed for the code, then yes, I would put it into version control. I'd do that right now in fact. If many people are adding in their own redirect rules in .htaccess files all over the place, you'll want to be able to:

  1. Roll back the changes.
  2. Point the finger! ;)
请远离我 2024-09-09 02:37:07

.htaccess mod_rewrite 比 php 端的路由要快得多,我会坚持使用 mod_rewrite 进行 url 操作

.htaccess mod_rewrite is waaaaaay faster than routing things on the php side, i would stick with mod_rewrite for url manipulation

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