当提供某个“物理”(静态)文件时,是否可以.htaccess将(301)重定向/重写到某个 URI?最初在哪个 URI 下提供此文件并不重要。
例子
在文件根目录下example.com有一个文件index.html。可以使用不同的 URI(取决于服务器配置)访问此文件,例如:
http://example.com/http://example.com/indexhttp://example.com/index.htmlhttp://example.com/index.html?foo=barhttp://example.com///////////index.html
使用像RewriteRule file(index.html) http://example.com/ [R=301,L]我这样的(伪!)规则可以指定此文件的规范 URI,而无需考虑所有可能的 URI 变体。