Bluehost.com Web Hosting $6.95

Re: mod_rewrite: absolute paths break rewriting

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 ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-02-2006
Yamaska
 
Posts: n/a
Default Re: mod_rewrite: absolute paths break rewriting

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:51 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0