重写规则导致“错误请求”当放置在虚拟主机文件中时

发布于 2024-12-18 11:09:49 字数 1100 浏览 2 评论 0原文

我的客户网络主机坚持将站点的重写规则放入虚拟主机文件中,但这会导致错误“错误请求”。尽管当我在本地服务器和其他类似站点上的 .htaccess 中放置相同的规则时,它运行得很好。规则如下:

    RewriteRule ^api/ index_rest.php [L]
    RewriteRule ^index_rest.php - [L]
    RewriteRule ^([^/]+/)?content/treemenu.* index_treemenu.php [L]
    RewriteRule ^var/([^/]+/)?storage/images(-versioned)?/.* - [L]
    RewriteRule ^var/([^/]+/)?cache/(texttoimage|public)/.* - [L]
    RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L]
    RewriteRule ^share/icons/.* - [L]
    RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|flash|images|lib|javascripts?)/.* - [L]
    RewriteRule ^packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
    RewriteRule ^packages/styles/.+/thumbnail/.* - [L]
    RewriteRule ^var/storage/packages/.* - [L]
    RewriteRule ^favicon.ico - [L]
    RewriteRule ^design/standard/images/favicon.ico - [L]
    RewriteRule ^robots.txt - [L]
    RewriteRule ^w3c/p3p.xml - [L]
    RewriteRule .* index.php

我的主机给了我一个错误日志,该日志位于位于此处,但我无法识别问题。非常感谢任何帮助。

My clients webhost insists on placing the Rewrite-rules for the site in the virtual host file, but this causes the error "Bad request". Although when I place the same rules in a .htaccess on my local server, and other similar sites, it works perfectly. Here are the rules:

    RewriteRule ^api/ index_rest.php [L]
    RewriteRule ^index_rest.php - [L]
    RewriteRule ^([^/]+/)?content/treemenu.* index_treemenu.php [L]
    RewriteRule ^var/([^/]+/)?storage/images(-versioned)?/.* - [L]
    RewriteRule ^var/([^/]+/)?cache/(texttoimage|public)/.* - [L]
    RewriteRule ^design/[^/]+/(stylesheets|images|javascript)/.* - [L]
    RewriteRule ^share/icons/.* - [L]
    RewriteRule ^extension/[^/]+/design/[^/]+/(stylesheets|flash|images|lib|javascripts?)/.* - [L]
    RewriteRule ^packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
    RewriteRule ^packages/styles/.+/thumbnail/.* - [L]
    RewriteRule ^var/storage/packages/.* - [L]
    RewriteRule ^favicon.ico - [L]
    RewriteRule ^design/standard/images/favicon.ico - [L]
    RewriteRule ^robots.txt - [L]
    RewriteRule ^w3c/p3p.xml - [L]
    RewriteRule .* index.php

My host has given me an error log which is located here, but I cannot identify the problem. Any help is greatly appreciated.

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

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

发布评论

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

评论(1

辞旧 2024-12-25 11:09:49

在 VirtualHost 上下文中使用时需要使用前导斜杠。

在 VirtualHost 上下文中,模式最初将与
主机名和端口之后、查询之前的 URL 部分
字符串(例如“/app1/index.html”)。

所以 ^... 必须是 ^/...

You need to use leading slashes when using in the VirtualHost context.

In VirtualHost context, The Pattern will initially be matched against
the part of the URL after the hostname and port, and before the query
string (e.g. "/app1/index.html").

So ^... must be ^/...

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