.htaccess RewriteCond -s(文件存在)
我正在抓狂...
尝试让 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 视为路径名并测试它是否存在,并且是大小大于零的常规文件。”
我已经:
- 确保文件存在
- 检查文件权限(即使这应该不重要,因为它是apache检查apache创建的文件)
- 尝试更改硬编码路径的%{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:
- Ensured that the files exist
- Checked the file permissions (even though this shouldn't matter as it is apache checking files apache has created)
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你能得到实际的html文件吗?
example.com/cache/normal/example.com/_.html
Can you get to the actual html file?
example.com/cache/normal/example.com/_.html