Any Concern with 500 Server errors?

I got a spike in Google Webmaster 500 server errors on the 19th and it is going up.

I changed the url structure of the pages from site com/innerpage/ to site com/innerpage

Initially, it was site com/innerpage with a folder called “innerpage” that had an index.php file which pulled content from content > innerpage.php

Now it is site com/innerpage.php and the updated htaccess removes the .php extension


ErrorDocument 404 http://www.site.com/404

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

RewriteEngine on
RewriteCond %{HTTP_HOST} ^site.com
RewriteRule (.*) http://www.site.com/$1 [R=301,L]

4.) If those older site.com/innerpage/ are typed in the address bar, it does not go to 404 page, it goes to Server error 500.
other mistypes do go to 404 error page

There are no links to these older page formats but Google webmaster tools is increasing with these 500 errors.

Should I be concerned?

What errors are showing in Apache’s error log?

lukkas,

First, follow SP’s suggestion and look at the errors to see what is wrong.

From my experience, 500 errors, though, are caused by ILLEGAL code in the .htaccess file. Okay, illegal is overboard. It’s simply code which is typographically or syntactically incorrect … and can bring an entire website down!

The code you show has the following errors:

ErrorDocument 404 http://www.site.com/404
# Error Document REQUIRES an absolute link so this should be some form of /.404.php
# I believe that the following code will handle your /404, though, but you should know how to do it correctly.

RewriteEngine on
RewriteBase /
# NOT necessary in the DocumentRoot and can cause directory level problems
# albeit it does not seem to be the case here
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
# Both of those are good but ...
RewriteRule ^(.*)$ $1.php [NC,L]

# MAJOR PROBLEMS:
#
# 1. The (.*) lazy code matches everything or nothing. THINK! What does it do for your /innerpage/?
#     It will redirect to /innerpage/.php, of course! I'm sure that you do NOT have nameless files
#     with .php extension lying around to collect these ridiculous links so you MUST protect against
#     the trailing / on files (best to 301 them to real links then add the .php file extension).
#     My advice is to use ([a-z]+) (for DirectoryRoot filenames) and not the lazy code.
#     My standard rant about this will follow.
#
# 2. The No Case flag has no business in a RewriteRule flag set because URIs ARE case sensitive!
#     Okay, this is not the 500 generator but it IS a 404 generator for you!

RewriteEngine on 
# Didn't you already take mod_rewrite out of "Comment Mode" above? 
# "Don't repeat yourself [i]repetitively[/i]."

RewriteCond %{HTTP_HOST} ^site.com
# You've forgotten the \\ before the dot metacharacter AND
# the No Case flag (because domain names are NOT case sensitive

RewriteRule (.*) http://www.site.com/$1 [R=301,L]
# I'm loathe to admit that (.*) is what you want here although you should use the Apache variable
# RewriteRule .? http://www.site.com%{REQUEST_URI} [R=301,L]

As promised, my Standard Rant # 1:

[rant #1][indent]The use of “lazy regex,” specifically the :kaioken: EVERYTHING :kaioken: atom, (.*), and its close relatives, is the NUMBER ONE coding error of newbies BECAUSE it is “greedy.” Unless you provide an “exit” from your redirection, you will ALWAYS end up in a loop![/indent][/rant #1]

Indeed, you MUST be concerned over code which is causing server errors, infinite loops, etc. It’s another case of knowing what your code is doing before you use it online! You just don’t want the tarnished reputation that they give you.

Regards,

DK

Your suggestion to replace the lazy " .* is " ([a-z]+)" - do you mean " ([a-z,A-Z,0-9]+)/([a-z,A-Z,0-9]+)/([0-9]+) " in its place ?

I know intermediate CSS and html, not programming so much. I was just looking for some quick help but you found other errors which could help.

I surely don’t want loops or bad code either because a correction is needed so I can rebuild another larger site.

This is a whole new site structure for me building (trying) with php.

I almost had a 2nd problem from the error log for you but I just fixed. And yes, I get more satisfaction from finding/solving it myself but some things are just over my head.

Sometimes, it is like bringing a musician into the middle of a discounted cash flow analysis course, yet I am neither.

lukkas,

You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.

Regards,

DK