Friday, February 4, 2011

redirection

Using .htaccess we can do the redirection

Regular Expression:-
. (full stop) - match any character
* (asterix) - match zero or more of the previous symbol
+ (plus) - match one or more of the previous symbol
? (question) - match zero or one of the previous symbol
\? (backslash-something) - match special characters
^ (caret) - match the start of a string
$ (dollar) - match the end of a string

redirect abc.com to abc.com/blog/
RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.abc.com$
RewriteRule ^/?$ "http\:\/\/www\.abc\.com\/blog" [R=301,L]

redirecting abc.com/def.com to xyz.com[ie primarydomain.com/addondomain.com to anotherdomain/any]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc\.com\/def\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.abc.com\/def\.com$ [OR]
RewriteRule ^/?$ "http\:\/\/www\.xyz\.com\/404.php" [R=301,L]


Redirecting parked domain to another website
RewriteEngine on
RewriteCond %{HTTP_HOST} ^parkedomain.com$
RewriteRule ^(.*)$ http://anydomain.com/$1 [R=301]

OR
RewriteCond %{HTTP_HOST} ^parkeddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.parkeddomain.com$
RewriteRule ^/?$ "http\:\/\/www\.otherdomain\.com" [R=301,L]

No comments:

Post a Comment