htaccess目录索引重定向寻找css错误的地方

2024-05-01

你好,在我的 htaccess 文件中,我放置了此代码以确保我的目录索引文件设置为

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 而不是

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]

您可以添加一个额外的RewriteRule http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule,这重写了css/, js/ and images/文件也是如此

# exclude files already asking for v2013
RewriteCond %{REQUEST_URI} !^/v2013/
RewriteRule ^(?:css|images|js)/.*$ /v2013/$0
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

htaccess目录索引重定向寻找css错误的地方 的相关文章

随机推荐