Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

.htaccess redirect all pages of old site to home page of new site

Hi,

Done lots of searching and testing but to no avail; I need an htaccess rule which will map

www.somedomain.com to www.somenewdomain.com

and

any pages of the old domain to www.somenewdomain.com

Redirect / http://somenewdomain.com no good

Any help much appreciated.

Daisy
0
daisydoos
Asked:
daisydoos
  • 2
  • 2
  • 2
  • +2
1 Solution
 
COBOLdinosaurCommented:
Redirect 301 / http://www.somenewdomain.com/

in the .htaccess in th root directory of the old site should re-direct everything
0
 
daisydoosAuthor Commented:
Hi,

This doesnt work - on www.somedomain.com/about.html it resolves to www.newdomain.comabout.htmll 
I need it to go to www.newdomain.com/ 
0
 
Ray PaseurCommented:
@daisydoos: Do you have a common script called at the top of all the pages of the old domain (you should, but not everyone has this)?

If you do, you have a PHP solution that is very easy to implement.  Try this in the common script right at the top:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.somenewdomain.com/");
exit;

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Alan HendersonCommented:
This should work for all pages, assuming that your .htaccess file is saved as a text file, that the directory/file structure is unchanged, and that your host allows htaccess.

Redirect 301 / http://www.somenewdomain.com

0
 
Alan HendersonCommented:
:(
Sorry. too slow!
0
 
COBOLdinosaurCommented:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Open in new window


Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.
0
 
PapertripCommented:
You can try adding this to .htaccess

RewriteEngine  on
RewriteCond %{HTTP_HOST} ^www.somedomain.com$ [NC]
RewriteRule ^(.*)$ http://www.somenewdomain.com [R=301,NC,L]

Open in new window


I am unable to test that right this second, but I believe it will work for what you want.
0
 
daisydoosAuthor Commented:
Hi,

COBOL, this still doesnt work for me - somedomain.com/about.html still going to somenewdomain.comabout.html, I've tried using PHP but this is also producing the same results.

I've tried it on another site, and the htaccess produces the same results - mod rewrite is enabled.

Daisy
0
 
PapertripCommented:
The syntax I provided should redirect www.somedomain.com/about.html to www.somenewdomain.com.
0
 
Ray PaseurCommented:
I've tried using PHP but this is also producing the same results.   Eh?  Click this link.
www.laprbass.com/RAY_temp_redirect.php
<?php // RAY_temp_redirect.php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.LandonBaseball.com/");
exit;
echo "<h1>YOU WILL NEVER SEE THIS</h1>";

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now