Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Apache - redirect port 81 to single page
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Clapper
Apprentice
Apprentice


Joined: 29 Sep 2003
Posts: 177

PostPosted: Thu Oct 28, 2004 2:48 pm    Post subject: Apache - redirect port 81 to single page Reply with quote

Hello,

Is it possible to configure apache to where, if anyone attempts to access the server on a singe port, port 81, that it goes to a specified web page, no matter what the trailing end of the url is?

How would I do this?

At one time I had a domain that ran on port 81. The server no longer runs on 81, but, I want to somehow direct all port 81 connections to a single page, informing them of this, and directing them to the root index page.

Any ideas?
Back to top
View user's profile Send private message
ocbMaurice
Tux's lil' helper
Tux's lil' helper


Joined: 14 Feb 2003
Posts: 90
Location: Switzerland

PostPosted: Thu Oct 28, 2004 3:25 pm    Post subject: Reply with quote

That should be possible with several methods. Not sure which is the best, as it is always when there is more than one way to do it.

with virtualhosts and mod_alias :

<VirtualHost *:81>
# if you want to redirect /abc to http://foo2.bar.com/abc
Redirect / http://foo2.bar.com/
# if you want to redirect all to a single page, you might use
RedirectMatch (.*) http://www.some.host/some.page
</VirtualHost>

or with mod_rewrite something like this might work too :

RewriteCond %{SERVER_PORT} ^81*
RewriteRule ^.*$ /homepage.max.html

of course, dont forget to set apache to listen on port 81 too :-)

I have not tested if the above will work, but IMO one of them should, just give it a try and otherwise read the manuals for mod_alias or mod_rewrite !

greets, Maurice

ps. It's no problem to run one apache on multiple ports, just lookup the "listen" option (http://httpd.apache.org/docs/mod/core.html#listen)
Back to top
View user's profile Send private message
Clapper
Apprentice
Apprentice


Joined: 29 Sep 2003
Posts: 177

PostPosted: Thu Oct 28, 2004 5:05 pm    Post subject: Reply with quote

ocbMaurice wrote:


<VirtualHost *:81>
# if you want to redirect /abc to http://foo2.bar.com/abc
Redirect / http://foo2.bar.com/
# if you want to redirect all to a single page, you might use
RedirectMatch (.*) http://www.some.host/some.page
</VirtualHost>



Thanks *so* much! This did it for me in 5 seconds of editing of apache.conf. I have been worrying about how to address this for a while!
Back to top
View user's profile Send private message
ocbMaurice
Tux's lil' helper
Tux's lil' helper


Joined: 14 Feb 2003
Posts: 90
Location: Switzerland

PostPosted: Thu Oct 28, 2004 5:31 pm    Post subject: Reply with quote

yu're welcome ;-)
Just a note, it's maybe better to use the alias* and not the redirect* options to save some cpu and bandwidth if both servers are on the same machine (read manual to get the difference) !
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
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