.htaccess: Forward ALL requests to another site
Question
I have to forward an existing website to another one.
I want to forward each and every request on the old site to the root of the new site.
Example:
http://oldsite.tld/index.php?mode=foo&action=bar
should be forwarded to http://newsite.tld/
and not http://newsite.tld/index.php?mode=foo&action=bar
.
Is this possible with .htaccess alone? I'd also have the possibility of using PHP.
Thanks.
Solution
Okay, I decided to do it with mod_rewrite, a simple Redirect
in the .htaccess didn't quite do the job.
Here's what I ended up using:
RewriteRule (.*) http://newsite.tld/? [R=301,L]
The ?
at the end of the URL makes sure all queries are ignored.
OTHER TIPS
Simply on the top of every file put
<?php
header('Location: http://newsite.tld');
?>
Run a quick prepend operation on all .php
files.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow