Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Struggling with 301 redirects in .htaccess

Struggling with 301 redirects in .htaccess

Struggling with 301 redirects in .htaccess

Please excuse me if this is not the correct forum for my problem.

I am trying to use .htaccess to redirect an old domain to a new one. The are many pages on the old domain, all in the same root directory. For simplicity, I want to redirect each of these old pages to the home page of the new domain (which is named index.html).

I have tried several variations of the syntax, including the following:

CODE -->

Redirect 301 / http://www.newdomain.com/
Redirect 301 / http://www.newdomain.com
Redirect 301 ^/ http://www.newdomain.com/
Redirect 301 / http://www.newdomain.com/index.html
Redirect 301 / http://www.newdomain.com/another_page.html
Redirect 301 index.htm http://www.newdomain.com/index.html 

Plus all of the above while omitting the www. prefix.

No matter what variation I use, the result is always the same. It correctly finds the new domain, but it always goes to my custom 404 error page.

Can anyone throw any light on this. Clearly, my basic syntax is correct, otherwise it wouldn't be going to the new site, but I don't understand why the new site is always going to the 404. I am sure that index.html exists on the new site and is the default page.

Thanks in advance.


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Struggling with 301 redirects in .htaccess

forum65: Apache: HTTP Server

You do not need the /index.html after the domain IF 'index.html' is in your list of 'index documents, because your rules will create a closed loop, and as the this is on the same physical server you need to specify when the redirect rule should end using the L flag.


RewriteEngine on
RewriteCond %{HTTP_HOST} ^old.tld [NC,OR]
RewriteCond %{HTTP_HOST} ^www.old.tld [NC]
RewriteRule ^(.*)$ http://new.tld/$1 [L,R=301,NC] 


Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: Struggling with 301 redirects in .htaccess

Thanks for your prompt reply, Chris, and also for pointing me to the Apache forum.

I'll try out your suggestion and report back.


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close