【发布时间】:2013-03-09 21:20:01
【问题描述】:
您好,在我的 htaccesss 文件中,我将这段代码放入以确保我的目录索引文件设置为
v2013/index.html
所以我把这段代码
DirectoryIndex v2013/index.html
然后我希望它看起来像 mydomain.com/Welcome,所以我添加..
RewriteEngine On
RewriteRule ^Welcome$ v2013/index.html [L]
我的问题是为什么 DirectoryIndex 不再工作.. 我如何告诉浏览器在 v2013 中查找 css,因为正在查找根目录。 (我认为是因为重写)所以我的页面没有风格.. =(
换句话说就是寻找 www.domain.com/css/sheet.css 的 insted
www.domain.com/v2013/css/sheet.css
答案在这里:
最终代码
DirectoryIndex v2013/index.html
RewriteEngine On
# exclude files already asking for v2013
RewriteCond %{REQUEST_URI} !^/v2013/
RewriteRule ^css/.*$ /v2013/$0
RewriteRule ^js/.*$ /v2013/$0
RewriteRule ^images/.*$ /v2013/$0
RewriteRule ^Bienvenido$ v2013/index.html [L]
【问题讨论】:
标签: .htaccess rewrite directoryindex