.htaccess RewriteCond -s(文件存在)

发布于 2024-10-20 17:50:06 字数 940 浏览 1 评论 0原文

我正在抓狂...

尝试让 Drupal Boost 在实时环境中工作。它可以在我的开发机器上运行,但在实际运行时遇到问题。

它依靠 .htaccess 重写规则来检查缓存目录中是否存在静态 html 文件,如果存在,则使用该文件进行重写。

我已经剥离了除核心重写规则之外的所有内容,因此它看起来像这样:

RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
RewriteRule .* cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

重写条件似乎不起作用(检查我的开发环境与实时环境相比发生的情况)。本质上,它是检查文件系统中是否存在 %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}.html(使用 -s 标志)。

来自 apache:

“将 TestString 视为路径名并测试它是否存在,并且是大小大于零的常规文件。”

我已经:

  1. 确保文件存在
  2. 检查文件权限(即使这应该不重要,因为它是apache检查apache创建的文件)
  3. 尝试更改硬编码路径的%{DOCUMENT_ROOT},例如/var/www/vhosts/mywebsite.com/httpdocs/cache/normal/www.mywebsite。 com/

任何人都可以提出前进的方向,或者尝试解决此问题的任何建议吗?

我查看过 Drupal 论坛,但在我看来这是一个 .htaccess 问题。

有人有使用 -s 的经验吗?

I'm pulling my hair out...

Trying to get Drupal Boost to work on a live environment. It works on my development machine, but having problems in getting it to work live.

It relies on an .htaccess rewrite rule to check if there is a static html file in a cache directory, and if it does, rewrite using this file.

I have stripped everything but the core rewrite rules, so it looks likes this:

RewriteCond %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
RewriteRule .* cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

It is the rewrite condition that doesn't appear to be working (checking what happens on my dev environment compared to the live one). Essentially it is checking to see if %{DOCUMENT_ROOT}/cache/normal/%{SERVER_NAME}%{REQUEST_URI}_%{QUERY_STRING}.html exists in the file system (using the -s flag).

From apache:

"Treats the TestString as a pathname and tests whether or not it exists, and is a regular file with size greater than zero."

I have:

  1. Ensured that the files exist
  2. Checked the file permissions (even though this shouldn't matter as it is apache checking files apache has created)
  3. Tried changing %{DOCUMENT_ROOT} for a hard coded path e.g. /var/www/vhosts/mywebsite.com/httpdocs/cache/normal/www.mywebsite.com/

Can anyone suggest a way forward, or anything to try to resolve this?

I have looked on Drupal Forums, but it seems to me to be a .htaccess problem.

Has anyone had experience of using -s?

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

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

发布评论

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

评论(1

零時差 2024-10-27 17:50:06

你能得到实际的html文件吗?

example.com/cache/normal/example.com/_.html

Can you get to the actual html file?

example.com/cache/normal/example.com/_.html

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