Redirect visitor by domain name

 

Redirect visitor by domain name

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.


Post a Comment



We use third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you.