Apache2Triad Help, Support and Development Forum Index Search Profile Log in to check your private messages Log in Register Memberlist Attachments Statistics Crew/Ranks Archive
 rewrite hostname to port
Google
Post new topic Reply to topic
Author Message
Joshua Meadows (DemoRic)
support
support


Joined: 29 Dec 2004
Posts: 783
Location: S.E. Kansas

PostPosted: Sun Dec 18, 2005 2:48 am Reply with quoteBack to top

I'm trying to figure a mod_rewrite rule that will redirect requests to a different port if the server name isn't one specified.

E.G.
host1 is on port 80
host2 is on port 80
host3 is on port 8080, but DNS points to port 80.
host4 is on port 8080, but DNS points to port 80.
host5 is on port 8080, but DNS points to port 80.

so what I need is a rewrite to change any request that aren't hosts 1/2 to port 8080. something like:
Code:
RewriteCond %{SERVER_NAME}!^https?://(www\.)?jaydium\.servehttp\.com/ [NC]
RewriteCond %{SERVER_NAME}!^https?://(www\.)?jaydium\.selfhost\.com/ [NC]
RewriteCond %{REQUEST_URI} ^/+.*$
RewriteRule ^/+(.*) http://%{SERVER_NAME}:8080/$1 [L,R,NC]
*which doesn't work.

Currently I use a perl script to accomplish this, but I would rather have apache do this directly and save bandwidth. Also of interest I changed my indexes to have cgi listed before php

index.cgi

Code:
#!C:/apache2triad/perl/bin/perl.exe
use warnings;
use strict;
print ("Content-type: text/html\n\n");
print "<html><head><title>".$ENV{'HTTP_HOST'}."</title></head><body><br />\n";
   if($ENV{'HTTP_HOST'}eq "jaydium.servehttp.com"){
      print "<center>Loading: <b>http://".$ENV{'HTTP_HOST'}."</b></center>";
      print "<META HTTP-EQUIV=\"Refresh\"\n";
      print "CONTENT=\"0; URL=index.php\">";
   }elsif ($ENV{'HTTP_HOST'}eq "jaydium.selfhost.com"){
      print "<center>Loading: <b>http://".$ENV{'HTTP_HOST'}."</b></center>";
      print "<META HTTP-EQUIV=\"Refresh\"\n";
      print "CONTENT=\"0; URL=index.php\">";
   }else{
      print "<center>Loading <b>http:// ".$ENV{'HTTP_HOST'}.":8080</b></center>";
      print "<META HTTP-EQUIV=\"Refresh\"\n";
      print "CONTENT=\"0; URL=http://".$ENV{'HTTP_HOST'}.":8080\">";
   }
print "</body></html>";
View user's profileSend private messageYahoo MessengerICQ Number
Display posts from previous:      
Post new topic Reply to topic


 Jump to:   



View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme
All times are GMT