htaccess directoryindex redirect looking for css w

2019-07-17 05:47发布

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]

2条回答
贪生不怕死
2楼-- · 2019-07-17 06:06

Where you use the css file don't type "css/style.css", write "/css/style.css". Adding a / takes you to the root. The html should look like this:

     <link href="/v2013/css/style.css" rel"stylesheet" type="text/css" />
查看更多
ゆ 、 Hurt°
3楼-- · 2019-07-17 06:20

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
查看更多
登录 后发表回答