Forum Moderators: phranque

Message Too Old, No Replies

Possible to combine SSI and RewriteRule?

Where ReWriteRule redirects to external URL

         

cschults

11:05 pm on Dec 21, 2009 (gmt 0)

10+ Year Member



I have a RewriteRule that works fine on my staging server.

For example:

^folder/some_path$ http://www.example.com/folder/some_path [R,L]

What I would like to do is this on my staging server:

<!--#include virtual="/folder/some_path"-->

But this doesn't seem to work. I assume it is because the value of virtual is not an actual file. Interestingly, this doesn't generate an error in the Apache log.

Some background: I have a script on my production server that returns a result set from a database. These results can be embedded on any page. What I'm trying to do is allow people previewing content on the staging server to see what results would appear once the page is published to the production server.

Note: not an option is to put a copy of the script on the staging server that accesses the production database.

Any ideas?

Thanks,

Chris

jdMorgan

11:41 pm on Dec 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It doesn't work because that is a local include -- it simply reads the local file contents into the current page 'right here' where this include directive is located.

mod_rewrite only affects incoming URL requests in the URL-to-filename translation and fixup phases of the Apache APi, and not direct file access requests to the filesystem occurring during the content-handling phase.

Instead of directly-including a file there, consider including a small PERL script that can make a request and 'go get' the necessary content, for example, using libwww-perl, lwp:simple, or lwp:trivial, etc. all of which have 'go fetch this URL' function support.

Jim

cschults

11:51 pm on Dec 21, 2009 (gmt 0)

10+ Year Member



Jim, as always, thanks for your assistance. Your reply is what I suspected, but wanted to verify.

g1smd

1:50 am on Dec 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Be aware that the redirect in your code is a 302 redirect; just in case you wanted a 301 instead.