htaccess的DirectoryIndex的重定向寻找的CSS错了地方 [英] htaccess directoryindex redirect looking for css wrong place

查看:162
本文介绍了htaccess的DirectoryIndex的重定向寻找的CSS错了地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我htaccesss文件我把这个code,以确保我的目录索引文件设置为

v2013 / index.html的

所以我把这个code

 的DirectoryIndex v2013 / index.html的
 

然后我想它看起来像mydomain.com/Welcome,所以我加..

  RewriteEngine叙述上
重写规则^欢迎$ v2013 / index.html的[L]
 

我的问题是,为什么DirectoryIndex的不工作了..我怎么能告诉浏览器查找内部v2013的CSS,因为正在寻找根。 (我想是因为重写),所以我的页面UNSTYLE .. =(

在换句话说正在寻找www.domain.com/css/sheet.css insted的的

www.domain.com/v2013/css/sheet.css

答案的位置:

最后code

 的DirectoryIndex v2013 / index.html的

RewriteEngine叙述上

#排除文件已经要求v2013
的RewriteCond%{REQUEST_URI}!^ / v2013 /
重写规则^ CSS /.*$ / v2013 / $ 0个
重写规则^ JS /.*$ / v2013 / $ 0个
重写规则^图像/.*$ / v2013 / $ 0个

重写规则^比恩韦尼$ v2013 / index.html的[L]
 

解决方案

您可以添加一个额外的重写规则 =nofollow的> <$ C $,它重写 CSS / JS / 图片/ 文件以及

 #排除文件已经要求v2013
的RewriteCond%{REQUEST_URI}!^ / v2013 /
重写规则^(?:CSS |图片| JS)/.*$ / v2013 / $ 0个
 

Hello in my htaccesss file i put this code to ensure that my directory index file is set to

v2013/index.html

so i put this code

DirectoryIndex v2013/index.html

Then i Want it to look like mydomain.com/Welcome, so i add..

RewriteEngine On
RewriteRule ^Welcome$ v2013/index.html [L]

My question is why DirectoryIndex not working anymore.. and how can i tell the browser to look for the css inside v2013, because is looking in the root. ( i think because of rewrite) SO MY PAGE IS UNSTYLE.. =(

In other words is looking for www.domain.com/css/sheet.css insted of

www.domain.com/v2013/css/sheet.css

THE ANSWER HERE:

FINAL CODE

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]

解决方案

You can add an additional RewriteRule, which rewrites the css/, js/ and images/ files as well

# exclude files already asking for v2013
RewriteCond %{REQUEST_URI} !^/v2013/
RewriteRule ^(?:css|images|js)/.*$ /v2013/$0

这篇关于htaccess的DirectoryIndex的重定向寻找的CSS错了地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆