php script does not always execute or too slowly 301 redirect

php script does not always execute or too slowly 301 redirect

am 23.01.2008 17:41:55 von mark Bannister

Hello,
PHP vesion 4.4.1
On our corporate web site we use a common script that is called via an
include at the start of every page.
We just made a major site change and have a long list of 301 redirects.
I decided to handle the 301's in the common script instead of htaccess.

Now in the logs we are getting a lot of 404 not found errors on pages
that should be redirecting. Most of these are from robots, but not all.
I was wondering if this was just a timeout issue. I am logging all
errors and do not see any occurring.

The sequence of events is:
request for a not found page handled by htaccess and passed to a
notfound.php page.
The first thing notfound.php does is include the common script. This
script checks an array for a redirected uri. If it matches it sends a
301 header with the new page and exits.

What is happening that on some occasions the client is getting a 404
and we are not showing any errors occurring in PHP?




--
Mark B

Re: php script does not always execute or too slowly 301 redirect

am 24.01.2008 14:56:08 von mark Bannister

mark Bannister wrote:
> Hello,
> PHP vesion 4.4.1
> On our corporate web site we use a common script that is called via an
> include at the start of every page.
> We just made a major site change and have a long list of 301 redirects.
> I decided to handle the 301's in the common script instead of htaccess.
>
> Now in the logs we are getting a lot of 404 not found errors on pages
> that should be redirecting. Most of these are from robots, but not all.
> I was wondering if this was just a timeout issue. I am logging all
> errors and do not see any occurring.
>
> The sequence of events is:
> request for a not found page handled by htaccess and passed to a
> notfound.php page.
> The first thing notfound.php does is include the common script. This
> script checks an array for a redirected uri. If it matches it sends a
> 301 header with the new page and exits.
>
> What is happening that on some occasions the client is getting a 404 and
> we are not showing any errors occurring in PHP?
>
>
>
>

I have changed the way the 301 header is sent
Was:
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.injection-moldings.com'.$page);

IS:
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.injection-moldings.com'.$page,FALSE,301);

I will play with it and remove the first header and also change the
replace header location, but this either worked OR the robots gave up....


--
Mark B