This is a discussion on Re: mod_rewrite: absolute paths break rewriting within the Apache Web Server forums, part of the Web Server and Related Forums category; Ian.H wrote: > Hi all.. > > I've been battling away with this issue all day and got ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Ian.H wrote:
> Hi all.. > > I've been battling away with this issue all day and got nowhere fast. I > have understanding of mod_rewrite along with regex and the likes and > already have many in place, but this one's stumped me. > > I'm trying to configure a semi-generic rewrite but absolute paths break. > > For example: > > > RewriteRule ^/foo/?(.*)$ /path/to/files/$1 [L] > > > naturally works fine for anything in the root 'files' dir in the above > example, but all links in the page, images and CSS are either missing or > broken (links break, rest is missing) as these are in the format of > '/css/styles.css', '/graphics/menu/foobar.png', > '/graphics/foobarbaz.png', the same as the links such as '/foo.php'. > > Now my problem is also that I don't know the depth of the directories in > all cases as can be seen with the 'graphics' dir mentioned above so > adding hardcoded depths in the regex isn't going to work. > > I've tried various combinations of RewriteRule and RewriteCond, searched > the net, read Apache's mod_rewrite manual pages until I'm blue in the > face but can't find a solution to this. I have come across some answers > in this group but they use a hardcoded dir depth as directory names / > depths are known, I need to this to work now for any dir depths and > anything in the future too, so expandability is also a key factor. > > The theory is that 1 subdomain will handle requests for multiple web > site locations stored on the same server. ie: > > > http://subdomain.domain.org/foo/.* -> /web_stuff/foo/.* > http://subdomain.domain.org/bar/.* -> /web_stuff/bar/.* > > > but as the paths in the HTML use absolute format, it always looks for > these under the root 'subdomain.domain.org' dir. > > Any info / advice / links to RTFM greatly appreciated =) > > > > Regards, > > Ian > Actually you wan t the relative path,,.. unless you use an alias in apache Alias /foo/ /real/hard/path/to/files/ Alias /bar/ /real/path/to/other/files/ Pete |