homepage Welcome to WebmasterWorld Guest from 23.20.44.136
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirecting with mod_rewrite or 301 permanent?
How to redirect a site that uses PHP to pull files from another site?
starbean




msg:1513793
 3:55 pm on Mar 6, 2003 (gmt 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

 

jdMorgan




msg:1513794
 4:28 pm on Mar 6, 2003 (gmt 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

starbean




msg:1513795
 5:47 pm on Mar 6, 2003 (gmt 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...]

jdMorgan




msg:1513796
 6:34 pm on Mar 6, 2003 (gmt 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

starbean




msg:1513797
 1:52 am on Mar 7, 2003 (gmt 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?

jdMorgan




msg:1513798
 2:05 am on Mar 7, 2003 (gmt 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

starbean




msg:1513799
 3:06 am on Mar 7, 2003 (gmt 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. :)

oLeon




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

yes, it will.

jdMorgan




msg:1513801
 7:57 pm on Mar 19, 2003 (gmt 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

starbean




msg:1513802
 12:39 am on Mar 20, 2003 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved