You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Mike Merritt <mm...@cteresource.org> on 2002/09/09 16:15:50 UTC
[users@httpd] URL Redirection with mod_rewrite
Apache folks,
I am finding that mod_rewrite is as complex as the manual says it is. :-) I have been through the mod_rewrite manual and the URL Rewriting Guide, as well as the email archive, and haven't yet been able to figure out how do accomplish my goal.
The goal is this: I have two different domain names, one old (vvcrc.tec.va.us) and one new (cteresource.org), pointing to the same IP address, same web site. As there are still a lot of links around the internet that point to the old vvcrc address, I'd rather not disable it, but I'd like it to automatically redirect the user to the corresponding cteresource.org page. Here are a couple of examples for clarity: If someone browses to http://vvcrc.tec.va.us (or http://www.vvcrc.tec.va.us), I'd like their browser to show them that they are at http://www.cteresource.org. If they click on a link to http://vvcrc.tec.va.us/ipg/index.html, I'd like for their browser to show that they are at http://www.cteresource.org/ipg/index.html.
The methods I have tried have not worked, and I haven't been able to find an example config that does exactly what I'm trying to accomplish (or maybe I have and I didn't recognize it). I'm running this as a virtual host on a Solaris server. I appreciate any assistance.
Thanks!
Mike
Re: [users@httpd] URL Redirection with mod_rewrite
Posted by Mike Merritt <mm...@cteresource.org>.
Joshua,
Thank you, thank you, thank you! Perfect. I went with method #1. Then I
got up and did the Happy Dance. :-)
Mike
>
> This question is answered at
> http://httpd.apache.org/docs/misc/FAQ.html#canonical-hostnames
>
> If you have access to httpd.conf, the easiest way to do this is to
> simply add a new virtualhost section, as in
>
> NameVirtualHost *
>
> <VirtualHost *>
> ServerName vvcrc.tec.va.us
> Redirect / http://www.cteresource.org/
> </VirtualHost>
>
> <VirtualHost *>
> ServerName www.cteresource.org
> DocumentRoot ...
> </VirtualHost>
>
> If you really want to use mod_rewrite, it would look something like this:
>
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^vvcrc.tec.va.us$ [NC]
> RewriteRule (.*) http://www.cteresource.org$1 [R,L]
>
> Joshua.
>
>
> ---------------------------------------------------------------------
> 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
>
---------------------------------------------------------------------
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
Re: [users@httpd] URL Redirection with mod_rewrite
Posted by Joshua Slive <jo...@slive.ca>.
Mike Merritt wrote:
> If they click on a link to
> http://vvcrc.tec.va.us/ipg/index.html, I'd like for their browser to
> show that they are at http://www.cteresource.org/ipg/index.html.
>
> The methods I have tried have not worked, and I haven't been able to
> find an example config that does exactly what I'm trying to accomplish
> (or maybe I have and I didn't recognize it). I'm running this as a
> virtual host on a Solaris server. I appreciate any assistance.
This question is answered at
http://httpd.apache.org/docs/misc/FAQ.html#canonical-hostnames
If you have access to httpd.conf, the easiest way to do this is to
simply add a new virtualhost section, as in
NameVirtualHost *
<VirtualHost *>
ServerName vvcrc.tec.va.us
Redirect / http://www.cteresource.org/
</VirtualHost>
<VirtualHost *>
ServerName www.cteresource.org
DocumentRoot ...
</VirtualHost>
If you really want to use mod_rewrite, it would look something like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^vvcrc.tec.va.us$ [NC]
RewriteRule (.*) http://www.cteresource.org$1 [R,L]
Joshua.
---------------------------------------------------------------------
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