开发者

.htaccess: Forward ALL requests to another site

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 s开发者_运维知识库hould 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.


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.


Simply on the top of every file put

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

Run a quick prepend operation on all .php files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜