I am really new to apache mod_rewrite module. I have a page with a name http://abcon my corporate intranet. I want users to be redirected to http://abc.somecompanyname.comwhen they type http://abcin a URL string. Can someone provide and give an example or point me in the right direction.
http://abc
http://abc.somecompanyname.com
I believe this should be a fairly simple question to answer. Thank you all for you.
-Mark
You could make VirtualHost's definition simple, like on this one, on a server processing requests for abc:
<VirtualHost *:80> ServerName abc RewriteEngine on RewriteRule ^/(.*)$ http://abc.somecompanyname.com/$1 [R,L] </VirtualHost>
Apache 2.4:
mod_rewrite, Redirect, .
<VirtualHost *:80> ServerName undesired.example.com ServerAlias example.com notthis.example.com Redirect / http://www.example.com/ </VirtualHost> <VirtualHost *:80> ServerName www.example.com </VirtualHost>
, . - , "" .
I found advice in Apache2. The URL rewriting guide worked better.
I ended up with:
RewriteEngine on RewriteCond %{HTTP_HOST} !^foo\.bar\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*) http://foo.bar.com/$1 [L,R]
The string "RewriteEngine on" was not included in the Apache2 example. Perhaps this is usually the default, but in my case I needed to add it.