httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Stevenson <t...@pc-tony.com>
Subject Re: [users@httpd] apache redirect
Date Mon, 03 Sep 2007 20:20:22 GMT


Mandy Singh wrote:
> Hi,
>  

[SNIP]

> Want to learn 2 things -
>  
> 1) Redirection without url bar url getting unchanged

For this there is an incredibly simple fix, which is often overlooked.
This is too add an alias to the vhost so that is will serve the content 
for both www. and suddomain.

	<VirtualHost *:80>
	...
	Servername www.exmaple.com
	ServerAlias subdomain.example.com
	...
	</Virtualhost>


Alternatively you could use reverse proxy, if the server that hosts www. 
is on an alternate server this is particularly useful.

	<VirtualHost *:80>
	...
	Servername suddomain.exmaple.com

	ProxyPass / http://www.example.com/
	ProxyPassReverse / http://www.example.com/
	ProxyPreserveHost On
	
	...
	</Virtualhost>


>  
> 2) Redirection with url also getting changed to www.example.com 
> <http://www.example.com>

Ok, this is very easy.

	<VirtualHost *:80>
	...
	Servername subdomain.exmaple.com
	Redirect permanent / www.example.com
	...
	</Virtualhost>

This is a simple example of how to redirect your subdomain to www, 
whilst ensuring the address bar is changed also.

>  
> What's the best way to do this?

This really does depend on your environment, but consider the load 
implications of proxying if the host is local, use something simple like 
the alias option.
>  
> At how many levels can this happen (DNS, Apache, etc)?


>  
> Which the best place to do this?

Most certainly within Apache, as it gives you finer control over what is 
or is not affected.
>  
> Any good documentation (easy to understand redirection doc somewhere)?
>  
The main HTTPd docs are very good, http://httpd.apache.org/docs/
Or the HTTPd wiki  http://wiki.apache.org/httpd/



> Let me know.
>  
> Thanks in advance,
> Mandy.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message