Welcome to WebmasterWorld Guest from

Message Too Old, No Replies

Is my internal redirect harming rankings?



10:27 am on Aug 18, 2010 (gmt 0)

5+ Year Member


I have a website that works like this:

I have a script called a content handler that checks the URL entered. So, when people go to my root url (www.domain.com for example) it defaults to a page using the following code:

// Show Default Page
$section = "home";
$page = "index";
header("Location: $global_site_url/$section/$page.html");

In this case, when people go to www.domain.com it goes to www.domain.com/home/index.html which is the home page. Other pages/urls go to their respective areas.

So.. is this harming my site rankings? Is it doing weird things in search engines eyes for my root domain?

My .htaccess file contains the following code:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+).html index.php?section=$1&page=$2 [NC]

If someone goes to a page directly (as in the proper file structure such as www.domain.com/products/product.php) I use this

$global_site_url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."index.html";
header("Location: $global_site_url");

Which may also be harming rankings?

I'd just like a second opinion really to see if I am doing things ok or making a real huge mistake.



4:25 pm on Aug 18, 2010 (gmt 0)

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

This does seem like it night be a problem. First, if you absolutely must redirect the domain root for some reason, you should use a 302 status redirect. But if you are redirecting any internal URL, then use a 301.

So the first thing I'd suggest is using a header checker to see what http status is being returned for the original request.


9:25 am on Aug 19, 2010 (gmt 0)

5+ Year Member

Hi. Thanks for your reply.

When using an online tool to check the root domain headers (I don't know if I can name which tool/site I'm using), this is part of the feedback/response I get:

HTTP/1.1 200 OK
Connection: close
Date: Thu, 19 Aug 2010 09:23:38 GMT
Server: Apache
Content-Language: EN-GB
Content-Type: text/html
Content-Type: text/html; charset=iso-8859-1
Client-Response-Num: 1
Client-Transfer-Encoding: chunked

Using another tool to check links and popular pages said that the www.domain.com had a header status for 302, but www.domain.com/home/index.html had a status of 200.

So, will the search engines view it as 200 or 302? I'm ranking pretty well in searches, but I don't know if this is preventing me ranking even higher.


12:46 pm on Aug 19, 2010 (gmt 0)

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

this is part of the feedback/response I get

The whole response matters - every URL that the server and user agent "discuss" when trying to resolve a request. In your case, it looks like you have a 302 redirect status on a request for your www hostname. Then that redirect goes to an internal URL that does resolve with a 200 OK.

Since the redirect is from the domain root, a 302 is recommended. I would not think this redirect is causing you any ranking trouble.


1:21 pm on Aug 19, 2010 (gmt 0)

5+ Year Member

That's brilliant news. Thank you for looking into this for me.


1:54 pm on Aug 19, 2010 (gmt 0)

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

Even if most search engines do figure out your intent, these external redirects nevertheless appear to be unnecessary, slow the "user experience" by resulting in two client-server transactions per "user" request, and create double log entries (one redirect, one 200-OK) for each of those requests, which may inflate and affect the usefulness of your site's "stats."

A better approach would be to avoid these external redirects entirely by replacing them with additional internal-rewrite rules in your .htaccess file or --if you prefer doing things with PHP-- changing the PHP code to "include and then echo the proper page content" instead of redirecting the client.

In PHP, sending a "Location" header to the client results in a 302-Found redirect.
In PHP, Sending a "Location" header plus a server status of 301 gives a 301-Moved Permanently redirect.
In PHP, "including" a file and then sending that file's contents to the client is essentially equivalent to an internal rewrite (URL-to-internal-filepath translation) in .htaccess using mod_rewrite.

I agree that you should never allow the situation where you link to a URL that is always 301-redirected, while linking to a URL that is always 302-redirected is a bit more "forgiveable" in search engines' eyes (and many fairly-big sites do this). But really, you should never redirect the client unless the requested URL is actually wrong in some way -- and never link to a "wrong" URL from your own site, regardless of the redirect code returned.

I defer to Tedster's learned judgment on the "level of SEO harm" here, but unnecessary redirects certainly cannot be good for a site.



1:59 pm on Aug 19, 2010 (gmt 0)

5+ Year Member

php header function by default do 302 redirect.


header("Location: $global_site_url/$section/$page.html",TRUE,301);

for 301 redirect.

Featured Threads

Hot Threads This Week

Hot Threads This Month