Home > Hosting, Html, Tech, Web > Redirect visitor by domain name

Redirect visitor by domain name

November 20th, 2007 Leave a comment Go to comments

Redirect visitor by domain name; Mod Rewrite – URL Rewriting

In some cases the same web site is accessible by different addresses, like byrev.net, www.byrev.net, byrev.blog-u.net and we want to redirect it to one address.

Case 1: www.byrev.net to byrev.net

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.byrev.net$ [NC]
RewriteRule ^(.*)$ http://blog.4rev.net/$1 [R,L]

In this case the requested URL http://www.byrev.net/foo.html would redirected to the URL http://byrev.net/foo.html.

Case 2: byrev.net to www.byrev.net

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.byrev.net$ [NC]
RewriteRule ^(.*)$ http://www.byrev.net/$1 [R,L]

In this case the requested URL http://blog.4rev.net/foo.html would redirected to the URL http://www.byrev.net/foo.html.

  1. No comments yet.
  1. No trackbacks yet.
GoCache - ByREV-Cache v1.0 - live served in : 0.151234 sec (gzip)