You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Srikanth NT <nt...@gmail.com> on 2008/03/12 12:36:59 UTC

[users@httpd] Redirect

Hi
recently we moved our servers to a different place and so we want to
redirect the pages hitting the previous server to the new server location.
Also we need to workout to redirect site address wrongly typed. Say for
example, instead of http://www.mywebsite.co.uk if user enters
my-website.comI want it to get redirected properly.

I tried writing a redirection.conf and include in httpd.conf before
including virtualhosts.conf

RewriteEngine on
RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 9

*RewriteCond     %{HTTP_HOST}
^(www\.){0,1}my(.)*website(.)*(\.)(com|co\.uk)$ [NC]
RewriteRule     ^(.*)$          http://www.mywebsite.co.uk [R=301,L]

RedirectMatch   ^/$             http://www.commonwebsites.co.uk/
*
If non matches, I want it to get redirected to the parent website. When I
tested it with my-website.com, it is redirecting me to commonwebsites.co.uk

I dont understand the reason. Googled enough but no idea.....

Thanks in advance,
Sri

Re: [users@httpd] Redirect

Posted by Joshua Slive <jo...@slive.ca>.
On Wed, Mar 12, 2008 at 7:36 AM, Srikanth NT <nt...@gmail.com> wrote:
>
> Hi
> recently we moved our servers to a different place and so we want to
> redirect the pages hitting the previous server to the new server location.
> Also we need to workout to redirect site address wrongly typed. Say for
> example, instead of http://www.mywebsite.co.uk if user enters my-website.com
> I want it to get redirected properly.

You might want to look at http://wiki.apache.org/httpd/CanonicalHostNames

>
> I tried writing a redirection.conf and include in httpd.conf before
> including virtualhosts.conf

In each of your virtual hosts you'll also need
RewriteEngine On
RewriteOptions inherit

>
> RewriteEngine on
> RewriteLog "/var/log/httpd/rewrite.log"

And what exactly do you get in the rewrite.log?

> RewriteCond     %{HTTP_HOST}
> ^(www\.){0,1}my(.)*website(.)*(\.)(com|co\.uk)$ [NC]

That regex is a little over-complicated. Don't group expressions with
() unless you really need to. You probably want something more like
^(www\.)?my.*website.*\.(com|co\.uk)$

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