How can I redirect an entire domain to just one webpage using .htaccess?

Jack Cola January 4, 2011
Pinterest Stumbleupon Whatsapp

I have a domain/website that I want to redirect all URL’s to one page on another domain through .htaccess.

Example:
www.domain.com to redirect to www.newdomain.com/webpage.html (that’s what I have know)
But I also want to redirect www.domain.com/$ to redirect to www.newdomain.com/webpage.html (where the $ is any page).

Basically, any page visited to www.domain.com should be redirected to www.newdomain.com/webpage.html.

Thanks.

Ads by Google

  1. Jack Cola
    January 7, 2011 at 12:40 am

    Thanks Mike,

    I have found a cleaner piece of code that works really well now.

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.newdomain.com/page.html [R=301,L]

    • Aibek
      January 10, 2011 at 8:34 am

      thanks for an update Jack!

  2. Mike
    January 6, 2011 at 3:16 pm

    Example using htaccess:
    Redirect 301 / http://www.newdomain.com/page.html

    Example using mod_rewrite:
    RewriteEngine On
    rewritecond %{http_host} ^olddomain.com
    rewriteRule ^(.*) http://www.newdomain.com/page.html [R=301,L]

    As for the htaccess redirect the new pages must not be in a subdirectory of the htaccess file. But if you are on a different host/account this won't concern you.

    • Jeff
      November 23, 2011 at 4:42 am

      Jack, works perfect for me! Thanks man!

  3. Jack Cola
    January 6, 2011 at 3:33 am

    I have solved my issue, but I am sure there is a better, more efficient way.

    My .htaccess file contains:

    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.domain.com$
    RewriteRule ^/?$ "http://www.newdomain.com/page.html" [R=301,L]

    ErrorDocument 404 http://www.newdomain.org/page.html

    --

    If you know have a cleaner way, please let me know