Question

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]
Was it helpful?

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

OTHER TIPS

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" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top