Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect Website Homepage Only

I have two different websites that are hosted on different servers. I would like to redirect the homepage of the old site (www.oldsite.com.au) to the homepage of the new site (newsite.com.au). However, I do not want any pages within the old site (www.oldsite.com.au/page) to redirect to the new one (newsite.com.au/page). So, www.oldsite.com.au must redirect to newsite.com.au, but any other pages or files within the old site must not redirect.

All the .htaccess ideas I've tried just redirect every file from the old site to the new one.

like image 991
Jesse Macleod Avatar asked Jul 07 '15 23:07

Jesse Macleod


People also ask

How do I redirect a website to my homepage?

The simplest way to redirect to another URL is to use an HTML <meta> tag with the http-equiv parameter set to “refresh”. The content attribute sets the delay before the browser redirects the user to the new web page. To redirect immediately, set this parameter to “0” seconds for the content attribute.

How can I redirect a website to another?

Redirects allow you to forward the visitors of a specific URL to another page of your website. In Site Tools, you can add redirects by going to Domain > Redirects. Choose the desired domain, fill in the URL you want to redirect to another and add the URL of the new page destination.

What is a 302 temporary redirect?

The HyperText Transfer Protocol (HTTP) 302 Found redirect status response code indicates that the resource requested has been temporarily moved to the URL given by the Location header.

What is a 301 redirect and how do I do it?

A 301 redirect is a permanent redirect that passes full link equity (ranking power) to the redirected page. 301 refers to the HTTP status code for this type of redirect. In most instances, the 301 redirect is the best method for implementing redirects on a website.


1 Answers

Try one of these:

RedirectMatch 301 ^/$ http://newsite.com.au/

or

RewriteEngine On
RewriteRule ^$ http://newsite.com.au/ [L,R=301]

If you don't want a 301 (permanent) redirect, remove the 301 from the RedirectMatch or the =301 from the square brackets in the rule's flags.

like image 132
Jon Lin Avatar answered Sep 28 '22 07:09

Jon Lin