How to redirect traffic to another site

Our test enviroinment is set up on our local server as a subdomain (

But Google has indexed these pages so that when clients are looking for the live site on Google they are sent to the test server.

Is there a way to set up a global redirect in the ini file or the htaccess on our test server so that any request for any page within is directed to the live website?

thanks experts!
Who is Participating?
käµfm³d 👽Commented:
You can try putting this in the htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule (.*)$1 [R=301,L]  

Open in new window

rascalAuthor Commented:
Sorry, didn't work - it still just took me to my local site
rascalAuthor Commented:
By the way, here is some info from a phpinfo on the mods installed;

core mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias mod_asis mod_auth_basic mod_authn_default mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_cgi mod_dav mod_dav_fs mod_dir mod_env mod_include mod_info mod_isapi util_ldap mod_log_config mod_mime mod_negotiation mod_setenvif mod_status mod_ssl mod_autoindex_color mod_php5

Do I need to explicitly install mod_rewrite? If so, how is that done?
hi you could setup the .htaccess to do a 301 redirect

here you have a link on how to configure in different ways according to your needs

In case you dont have .htaccess you could do redirect for individual files using php header
header("Location: http://newlocation",TRUE,301);

also you could set the Google Webmaster central for the domain , and from there make the redirect
rascalAuthor Commented:
Sorry, that did in fact work - I had an incorrectly named htaccess file. Fixed now. Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.