views:

48

answers:

2

Hello.

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.

A: 

Simply on the top of every file put

<?php
    header('Location: http://newsite.tld');
?>

Run a quick prepend operation on all .php files.

Josh K
Is this the only way? I was hoping for a more "elegant" approach, but if that's the only way, I'll do it. Thanks.
No, you could also add a `.htaccess` redirect, but I'm not sure of the exact syntax on that and didn't want to look it up at 6:20 AM.
Josh K
A: 

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.