Forum Moderators: phranque

Message Too Old, No Replies

redirecting an virtual include

RewriteRule fails if file called via a virtual include

         

matc

8:56 am on Jan 12, 2005 (gmt 0)

10+ Year Member



Hello,

I would like to find a way of successfully redirecting a call to one of our files made through a virtual include. The following redirect works quite happily when the file request is made directly through the browser address bar but if I call it via a virtual include it fails to redirect. This is an example of one of 500 redirects that will have to be made, all being piped through the same template_portal.sssi just with different params being passed.

Any help on where I'm going wrong here would be most appreciated?

The file request example:
<!--#include virtual="/path/to/dir/file.shtml" -->

Present RewriteRule example:
RewriteRule ^file.shtml$ [site.co.uk...] [R,L]

Many thanks, mat

jdMorgan

3:16 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The answer is simple, but you may not like it:

mod_rewrite is a URL-to-filename or URL-to-URL rewriting engine, i.e. it rewrites URL requests coming into the server via HTTP from a client browser or search engine spider.

Virtual includes are direct file includes which take place entirely within the server filesystem, and do not use HTTP connections.

Therefore, mod_rewrite cannot have any effect, and the various Redirect directives of mod_alias can't either. A redirect implies HTTP, and includes don't use HTTP.

I'd suggest you look into using *nix symlinks to accomplish what you need.

Jim

matc

10:38 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



Hi jdMorgan,

Thanks for the reply and a very valid point about the ssi and method. I really should have recalled that. I think that I was made without the 'analytical approach' module bundled so thanks for putting me back on track.

As other Company Joes look after the head servers here theres little chance of getting a list of symlinks into place. That being the case I'll probably look at zero'in the contents of the file being called and inserting/daisy chaining an include to it until we can let our affiliates update their pages.

Thanks

mat