.htaccess redirect root to folder

I have two independend websites on my server. Of which one website is located in a subfolder of the other. Both websites are accessible over two different domains. Following the folder structure on my server:

/www                <- one.com
    /folder         <- two.com

Therefore, if I want to access website two I can do so with the following URLs:


My problem: Using absolute paths to include files (css/js/img) in website two, I need to adapt my root depending over which URL the user access website two. Following an example for illustration:

The html file /www/folder/index.html contains an image:

<img src="/assets/img.jpg" />

If the user access this html file via the domain one.com/folder/index.html the image source path gets translated to one.com/assets/img.jpg where it won't find any image. Correct would have been one.com/folder/assets/img.jpg (one notice the folder in the path). Obviously, if the user calls two.com/index.html the problem doesn't exist.

Therefore, I thought I would change the root (base directory) of website two via .htaccess mod rewrite depending on which URL gets called. Following the simple pseudo code I would like to implement:

if url == one.com/folder*
    root = /folder/
    root = /

And following what I got so far for my .htaccess file:

RewriteEngine on
RewriteCond   %{HTTP_HOST}   ^(www\.)?one\.com
RewriteRule   ^/(.*)$  /folder/$1  [R]

Unfortunately, it seems as if I am missing something here. So far it doesn't work. Any advice is much appreciated!


You can place this rule in /www/.htaccess folder:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(assets/.+)$ /folder/$1 [L,NC,R=301]

Need Your Help

What happens if someone else uses my disqus shortname?


What happens if someone else uses my disqus_shortname?

QuickTest Pro automated testing

testing qtp

I have three easy questions.