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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.