Reputation: 23587
I am working on a specific condition on production environment where I need to redirect user to third part in case a specific url.
I am aware that rewrite rule can be used for this case, however I came across Redirect
in Apache which can be used if resource moved to another server.
Can any one help me to understand the correct way to do this, I want use for this URL 'www.mysite.com/some/optional parameter/testpage' and mysite.com/some/optional parameter/testpage
to redirect to http://testpage.mysite.com/
#With Redirect
Redirect "www.mysite.com/testpage" "http://testpage.mysite.com/"
Redirect "mysite.com/testpage" "http://testpage.mysite.com/"
is this correct way to achieve this or I need to take a different approach.
Upvotes: 1
Views: 65
Reputation: 785481
You cannot use Redirect
directive for matching host name in request. Better to use mod_rewrite
and do a 301
redirect.
RewriteEngine On
RewriteCond %{HTTP_HOST} ([^.]+\.[^.]+)$ [NC]
RewriteRule (?:^|/)(thepact)/?$ http://$1.%1 [L,NC,R=301]
Upvotes: 1