[users@httpd] mod_rewrite and relative URLs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have the following requirements for a site I'm building:

- For bureaucratic reasons, I have only one UNIX account, only one 
subdomain, and no access to httpd.conf itself.  (That may change, so if 
you can think of a solution that would otherwise work, please post it!)

- I wish to have "system root" (my term) subdirectories /prod, /staging, 
and /dev to hold the production site, ready-for-production, and 
development versions of the site.

- The main content for each site is currently being generated by 
MovableType, and will be stored in $SYSTEM_ROOT/mt-pages.  (I don't like 
having subsystem-specific files in the root directory.)

- Each site also uses other subsystems like vBulletin, a survey script, 
etc., which are stored in $SYSTEM_ROOT/forum, $SYSTEM_ROOT/survey, etc.

- Requests for www.example.com/file.ext should be rewritten to 
www.mysite.com/prod/file.ext.

- Requests for any www.example.com/$SYSTEM_ROOT/file.ext should be 
rewritten to $SYSTEM_ROOT/mt-pages/file.ext.

- BUT requests for www.example.com/$SYSTEM_ROOT/subdir/file.ext should 
remain unchanged.

So far, so good.  I have RewriteRules in an .htaccess in ServerRoot to 
point it to prod, and similar rules in each $SYSTEM_ROOT dir to point 
into mt-pages for any filename with a dot in it.  (I'm OK limiting 
myself to directories without dots.)

The problem, of course, is that if I request 
http://www.example.com/index.html, which gets rewritten to 
http://www.example.com/prod/mt-pages/index.html, any relative links to, 
say, "images/logo.gif" will look for /images/logo.gif, not /prod/mt-
pages/images/logo.gif.

I can solve this by adding a BASE tag to each page, or by using absolute 
URLs, but that kills the point of having these mirror-image test 
systems.

I could also solve it by explicitly checking for each known subsystem in 
the .htaccess file, rather than assuming any directory to be a top-level 
subsystem, but I'd prefer to avoid that.

Is there some solution with mod_rewrite, mod_alias, or something else 
that will let me rewrite both URLs and the content base?  This seems 
like it ought to be a common problem.


-- 
Jay Levitt                | 
Wellesley, MA             | I feel calm.  I feel ready.  I can only
Faster: jay at jay dot fm | conclude that's because I don't have a
http://www.jay.fm         | full grasp of the situation. - Mark Adler


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux