Search code examples
.htaccessurl-rewritingdirectoryindex

htaccess directoryindex redirect looking for css wrong place


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]

Solution

  • 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