So this is my scenario:
I have 1 static IP and 2 servers. 1 server is a web server the other is a mail server. I have a router as a hardware firewall with all the ports are set that require passthrough to internal ip addresses .
If a user types the url http://www.domain.com they see that website. If the user wants to access webmail they type in the url http://mail.domain.com but still see http://www.domain.com
I have set the webmail domain to be accessible via port 8080 on the mail server and if the user types the url http://mail.domain.com:8080 it works no problem but not with http://mail.domain.com.
So this is my issue:
In my httpd.conf I want to setup a Redirect 301 so that when the user types in http://mail.domain.com they get redirected to http://mail.domain.com:8080
I'd prefer not to use .htaccess and keep the directives in the httpd.conf
Thanks...
-
There is at least 2 way to do this:
Create 2 virtual host one for www.domain.com and one for mail.domain.com and then put your RedirectMatch directive in the second one.
You could also use the ProxyPass directive in the mail.domain.com virtual host to make it working like a reverse proxy and have mail.domaine.com:80 working directly without redirectionUse mod_rewrite like this to only redirect for the mail.domain.com url with a rule like that
RewriteCond %{HTTP_HOST} ^mail.domain.com$ [NC]
RewriteRule ^(.*) http://mail.domain.com:8080/$1 [R=301]with mod_rewrite you can also do a reverse proxy with a rule like (mail.domain.com should resolve to the internal IP)
RewriteCond %{HTTP_HOST} ^mail.domain.com$ [NC]
RewriteRule ^(.*) http://mail.domain.com:8080/$1 [P]
From radius -
You'll need to create a virtual host on your main web server that responds to web requests for the "mail.domain.com" address. Take a look at the Name-based Virtual Host documentation on the Apache website. You'll also need a mod_rewrite rule to do the redirection. Your configuration would look something like this:
NameVirtualHost *:80 <VirtualHost *:80> ServerName mail.domain.com RewriteEngine On RewriteRule (.*) http://mail.domain.com:8080/\1 [R=301,L] </VirtualHost>
radius : Rewrite is useless if a virtualhost is created, RedirectMatch will be probably fastertroyengel : what are you talking about radius? Rewrite is perfectly fine in a virtualhost as listed above. The code is a little broken (use $1 not \1) but other than that it's good.From Peter Murray
0 comments:
Post a Comment