|
|
A different approach
I stumbled upon the RegisterResource trick last week while reading O'Reilly's Mac OS X Panther Hacks, but their approach depends on two Apache directives for each rule you want to set up -- one with the RegisterResource line, and another with a Redirect statement. I came up with a different approach to publishing URLs that aren't on my server that only requires one Apache rule per published URL. First, you need a CGI script that takes a URL as an argument and responds with an HTTP directive to go to that URL. Here's one way to do it:
$cat ~/Sites/re.pl
#!/usr/bin/perl -T
use strict;
use warnings;
my $url = $ENV{'QUERY_STRING'} || "http://some/default/page/";
print "Location: $url\n\n";
$ ls -l ~/Sites/re.pl
-rwxr-xr-x 1 www www 337 Aug 24 20:37 /Users/you/Sites/re.pl
$ ~/Sites/re.pl
Location: http://some/default/page/
$
If you can get similar behavior as what I show above, you're most of the way there. If you don't like Perl, this script could probably be rewritten in PHP, and can certainly be done in Python or even a Bourne shell script, but I do like Perl, and this was easy to do and I already have my Apache set up to serve mod_perl. YMMV. Once you have the redirect script in place, set up as many offsite redirects as you want, prefixing them with this redirect script's relative URL, like this: RegisterResource "Some name" /re.pl?http://some/other/server Restart Apache and everything will work just fine. Bouncing through your little re.pl script should be fast (most users shouldn't notice the delay), and as a bonus (if you're in to this sort of thing) you get a record of the activity in your Apache log. Not that there's anything wrong with this <virtualhost> idea, but it seems a lot more complicated than doing it this way... :-) --- |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|