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.

1
  • Hmmmm. Not exactly working guys. Commented May 28, 2009 at 14:13

2 Answers 2

3

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]
Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.