On Fri, 4 Aug 2000, kapil sharma wrote:

> Hi,
> I am using apache 1.3.12 with Redhat 6.2. I want to redirect  one url to
> other url. For example if some request comes for
> http://foo.com
> then the url should redirect to
> http://www.foo.com
> 
> What should i do for that?

Assuming foo.com is running apache and answering HTTP requests, Apache can
provide the rewriting with mucking up your pages. Use something like the
following in httpd.conf (I stick this within a <VirtualHost> block):

RewriteEngine on

RewriteCond %{HTTP_HOST}   !^www.foo.com
RewriteCond %{HTTP_HOST}   !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*)         http://www.foo.com:%{SERVER_PORT}/$1 [L,R]

RewriteCond %{HTTP_HOST}   !^www.foo.com
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.foo.com/$1 [L,R]



In my case, foo.com and www.foo.com resolve to the same IP. These rules
rewrite everything that isn't already http://www.foo.com, very handy when
your webserver has a dozen different names, keeps the logs clean.


One could probably do that all in one set of conditions and rewrite rule,
that is left as an exercise for the reader. :)


Bill Carlson
------------
Systems Programmer    [EMAIL PROTECTED]    |  Opinions are mine,
Virtual Hospital      http://www.vh.org/        |  not my employer's.
University of Iowa Hospitals and Clinics        |




_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to