【发布时间】:2015-12-15 05:46:34
【问题描述】:
我正在使用以下重写规则:
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI} -f [or]
RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI}/index.html -f [or]
RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI}index.html -f
RewriteRule ^(.+) static/$1
它们都成功地在 static 目录中提供文件,而无需在 url 中包含 static/。唯一的区别是,当我没有尾部斜杠时,static 目录会像外部重定向一样添加到 URL。
因此,
http://example.com/products/index.html --> http://example.com/products/index.html
和
http://example.com/products/ --> http://example.com/products/
但是,
http://example.com/products --> http://example.com/static/products/
有没有办法让索引文件从/static/products 目录提供,而不像其他两种情况一样在url 中显示static 目录?
【问题讨论】:
标签: .htaccess mod-rewrite redirect