Redirect website to another website

I want to redirect my old website to new website. I want to do this for main domain only, not sub pages.
For Example:
I have a website “”. I want to redirect “” to “”.
But if a visitor visits “”, he must not redirect. He should see the content on “”. Is this possible?

And 1 more thing. I get this error when someone visits a page that is not available. I want to redirect error page to home page.

Just put this in /index.php of

<?php header("location:"); ?>


I want to do this with .htaccess.

I don’t think that’s possible without redirecting all pages


Not possible.

You need to create a rule to override the redirect rule, but the only way to override it is to create another redirect.


Writing it just by heart (haven’t tested this), you should be able to redirect a specific URL using a .htaccess like like this:

RedirectMatch "^/$" ""

The standard Redirect statement does prefix matching, whereas you can do exact matching with RedirectMatch, which allows for some other redirect options.