views:

343

answers:

2

On my hosted server, the files are located here:

/usr/home/user1/public_html

I have to access the files using something like this: http://server1.example.com/user1/

However, all my files use absolute paths to reference CSS / Images / JS files.

So, my requests for these assets look like this:

http://server1.example.com/images/homepage/ver2/logo-black.png

Yet, they are not found because they live here:

http://server1.example.com/user1/

How do I tell Apache to use this path to look for files. Thanks.

A: 

If your asset directories would be called images, css and javascript, you might use the following in your Apache configuration:

RewriteEngine On
RewriteRule ^/(images|css|javascript)(/.*)$ /user1/$1$2
molf
+1  A: 

You could simply strip user1 out of the URL:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /user1/
RewriteRule ^/user1/(.*) /$1 [L,R=301]

RewriteRule !^/user1/ /user1%{REQUEST_URI} [L]
Gumbo