我的客户端webhost坚持在虚拟主机文件中放置网站的重写规则,但这会导致错误“错误请求”。虽然当我将相同的规则放在我的本地服务器和其他类似网站上的.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
我的主机给了我一个located here的错误日志,但我无法确定问题。非常感谢任何帮助。
答案 0 :(得分:4)
在VirtualHost上下文中使用时,您需要使用前导斜杠。
在VirtualHost上下文中,最初将匹配模式 主机名和端口之后以及查询之前的URL部分 字符串(例如“/app1/index.html”)。
因此^...
必须为^/...