Welcome to WebmasterWorld Guest from 54.196.153.46

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirecting with mod_rewrite or 301 permanent?

How to redirect a site that uses PHP to pull files from another site?

     
3:55 pm on Mar 6, 2003 (gmt 0)

New User

10+ Year Member

joined:Feb 26, 2003
posts:8
votes: 0


Here is my situation in a nutshell: MyOldDomain.com was banned by google 2 months ago. I rushed to create MyNewDomain.com on a new server. It uses SSI/PHP to pull files from MyOldDomain.com. (see below). When I learned that MyOldDomain.com is back in google with a good ranking I rushed a robots.txt to disallow googlebot from MyNewDomain.com but I may have been too late. To be safe I want to redirect traffic from MyNewDomain.com to MyOldDomain.com

I'm not sure if I can use the mod_rewrite because MyNewDomain.com uses PHP to pull files from MyOldDomain.com

Here is how it works: since all files in MyOldDomain.com are in .html and not .php, I'm using an SSI command in MyNewDomain.com as in this example:
PHP file: <?include("http://www.MyOldDomain.com/myfile.htm"?>
HTML file: <!--#include file="myfile.php" -->

Is it possible to use a mod_rewrite redirect in this case?

Or should I create 250 files with this command:
<meta http-equiv="refresh"content="0;url=http://www.MyOldDomain.com/filename.htm">

Or should I be using this in the htaccess file:
redirectpermanent /oldpage1.htm [newurl.com...]
redirectpermanent /oldpage2.htm [newurl.com...]

I'm a tech dilettante. A friend helped me set up the PHP and I gathered the above redirect info from forums. I have never dealt with a htaccess file before. All I know is that my current htaccess file looks like this:

Options Indexes FollowSymLinks Includes
AddType application/x-httpd-cgi .cgi
AddType text/x-server-parsed-html .html

AddType text/html .shtml
AddHandler server-parsed .htm

4:28 pm on Mar 6, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


starbean,

Your web root .htaccess will be invoked on your new server before any php processing takes place. Therefore, I believe you will be able to fix your problem simply by placing the following line in your new server's .htaccess file:


RedirectPermanent / http://www.oldomain.com/

This will redirect any request to your newserver back to your old server.

I hope I understood your question! If not, it should be pretty obvious when you try the above - Do it when your site traffic is low!

Jim

5:47 pm on Mar 6, 2003 (gmt 0)

New User

10+ Year Member

joined:Feb 26, 2003
posts:8
votes: 0


Thanks Jim! Do I place that line RedirectPermanent / [oldomain.com...] on the top or the bottom of the htaccess file? Does it make any difference where it is?

Is it OK if I have the htaccess file like this:

Options Indexes FollowSymLinks Includes
AddType application/x-httpd-cgi .cgi
AddType text/x-server-parsed-html .html

AddType text/html .shtml
AddHandler server-parsed .htm

RedirectPermanent / [OLDDOMAIN.com...]

6:34 pm on Mar 6, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Starbean,

Well, technically, you don't need any of the other stuff any more, since any and all requests will be redirected. It really wouldn't matter either way, but putting it at the top would be more efficient if you want to keep the other lines for now.

Jim

1:52 am on Mar 7, 2003 (gmt 0)

New User

10+ Year Member

joined:Feb 26, 2003
posts:8
votes: 0


Thanks Jim. The redirect command is working well, but it is causing me a problem with the robots.txt file.

Because of the redirect command, RedirectPermanent / [OLDDOMAIN.com...] the validator is unable to check the robots.txt file from MyNewDomain, instead it validates the robots.txt file from MyOldDomain.

The robots.txt in MyNewDomain.com reads:

User-agent: *
Disallow: /

And the robots.txt file from MyOldDomain.com reads:

User-agent: *
Disallow: /a/
Disallow: /f/
Disallow: /cgi-bin/

I worry that googlebot will be unable to read the robots.txt file from MyNewDomain. In this situation, how can I disallow googlebot from indexing MyNewDomain.com?

2:05 am on Mar 7, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Understand that with the redirect in place, your new_domain - for practical purposes - no longer exists. Robots cannot access any of its content because they now get redirected to old_domain unconditionally. So, there is nothing there that they can access, and there is therefore no need to disallow access.

The robots.txt checker is seeing - and showing you - exactly what the spiders will see, a redirect to old_domain.

HTH,
Jim

3:06 am on Mar 7, 2003 (gmt 0)

New User

10+ Year Member

joined:Feb 26, 2003
posts:8
votes: 0


I'm learning a lot, thanks Jim :)

When googlebot follows websites' outbound links to MyNewDomain.com only to be redirected to MyOldDomain.com will MyOldDomain receive google's ranking credit for these outbound links?

If the answer is yes, it will save me from having to notify all those sites to update their links. :)

7:44 pm on Mar 19, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 15, 2000
posts:482
votes: 0


yes, it will.
7:57 pm on Mar 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


starbean,

Sorry - I missed your last post! :o

As oLeon states, you'll be OK with the redirect in place, but it would still be a good idea to try to get those incoming links updated. You will focus your domain-branding and avoid having two hits on your server for every visitor using those old links.

Jim

12:39 am on Mar 20, 2003 (gmt 0)

New User

10+ Year Member

joined:Feb 26, 2003
posts:8
votes: 0


Thanks Jim :) There is something else that maybe you can help me with. I have a php script that creates an error log file for my 404. It lists all my files that contain link errors. Do you know of a script that will only list internal link errors as "linkname.htm" instead of listing just the file name? Since my files are quite large and I have dozens of internal links, such script would be more useful to me than the one that just list file names.