500 Errors

Hey guys,
I am doing a crawl test on my site (http://www.fasttracksites.com/) checking for issues and a lot of my pages come back as 500 errors even though the links still work. Any idea whats going on?

Heres the link to the crawl test: http://www.seomoz.org/crawl-test/crawl

in my index.php I have this code:


if ($_SERVER['HTTP_HOST'] == "fasttracksites.com") {
	//redirect
	header("HTTP/1.1 301 Moved Permanently");
	header("Location: http://www.fasttracksites.com".$_SERVER['REQUEST_URI']);
	exit; 
}
elseif ($_SERVER['REQUEST_URI'] == "/index.php") {
	//redirect
	header("HTTP/1.1 301 Moved Permanently");
	header("Location: http://www.fasttracksites.com");
	exit; 
}

Heres my .htaccess files:

<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteEngine on

  RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule ^applications/?$ applications.php [L]
  RewriteRule ^contact/?$ contact.php [L]
  RewriteRule ^company/?$ company.php [L]
  RewriteRule ^design_process/?$ design_process.php [L]
  RewriteRule ^domains/?$ domains.php [L]
  RewriteRule ^error/([^/\\.]+)/?$ error.php?error=$1 [L]
  RewriteRule ^ftsbts/?$ ftsbts.php [L]
  RewriteRule ^ftsuploadgallery/?$ ftsuploadgallery.php [L]
  RewriteRule ^ftsclms/?$ ftsclms.php [L]
  RewriteRule ^ftscms/?$ ftscms.php [L]
  RewriteRule ^ftsinventorymanager/?$ ftsinventorymanager.php [L]
  RewriteRule ^ftspl/?$ ftspl.php [L]
  RewriteRule ^ftspns/?$ ftspns.php [L]
  RewriteRule ^ftsrs/?$ ftsrs.php [L]
  RewriteRule ^ftssafs/?$ ftssafs.php [L]
  RewriteRule ^ftssnts/?$ ftssnts.php [L]
  RewriteRule ^ftsss/?$ ftsss.php [L]
  RewriteRule ^ftsssforum/?$ ftsssforum.php [L]
  RewriteRule ^ftstts/?$ ftstts.php [L]
  RewriteRule ^hosting/?$ lhosting.php [L]
  RewriteRule ^lhosting/?$ lhosting.php [L]
  RewriteRule ^license_agreement/([^/\\.]+)/([^/\\.]+)/?$ license_agreement.php?file_requested=$1&name=$2 [L]
  RewriteRule ^mshosting/?$ mshosting.php [L]
  RewriteRule ^networking/?$ networking.php [L]
  RewriteRule ^news/?$ news.php [L]
  RewriteRule ^portfolio/?$ portfolio.php [L]
  RewriteRule ^privacypolicy/?$ privacypolicy.php [L]
  RewriteRule ^register/?$ register.php [L]
  RewriteRule ^reseller/?$ reseller.php [L]
  RewriteRule ^seo/?$ seo.php [L]
  RewriteRule ^sitemap/?$ sitemap.php [L]
  RewriteRule ^services/?$ services.php [L]
  RewriteRule ^survey/?$ survey.php [L]
  RewriteRule ^terms/?$ termsandconditions.php [L]
  RewriteRule ^testimonials/?$ testimonials.php [L]
  RewriteRule ^unsubscribe/?$ unsubscribe.php [L]
  RewriteRule ^webdesign/?$ webdesign.php [L]
</IfModule>

AddType x-mapp-php5 .php

ErrorDocument 400 http://www.fasttracksites.com/error.php?error=400
ErrorDocument 403 http://www.fasttracksites.com/error.php?error=403
ErrorDocument 404 http://www.fasttracksites.com/error.php?error=404
ErrorDocument 500 http://www.fasttracksites.com/error.php?error=500

Chris,

Well, yes, however, as a “technique,” I would move your core directives to the top, the core module directives after that then the mod_rewrite (additional module) directives in a group after that - FOR CLARITY! You’ve intermixed directives in a way to make your logic hard to follow.

AddType x-mapp-php5 .php

ErrorDocument 400 http://www.fasttracksites.com/error.php?error=400
ErrorDocument 403 http://www.fasttracksites.com/error.php?error=403
ErrorDocument 404 http://www.fasttracksites.com/error.php?error=404
ErrorDocument 500 http://www.fasttracksites.com/error.php?error=500

Options -MultiViews

Redirect /[COLOR="Red"](.*)[/COLOR]$ http://www.fasttracksites.com/$1 [COLOR="Red"][R=301][/COLOR]
Redirect /index\\.php$ http://www.fasttracksites.com/ [COLOR="Red"][R=301,L] [/COLOR]
Redirect /applications /applications.php[COLOR="Red"] [L][/COLOR]
Redirect /contact /contact.php[COLOR="Red"] [L][/COLOR]
Redirect /company /company.php[COLOR="Red"] [L][/COLOR]
Redirect /design_process /design_process.php[COLOR="Red"] [L][/COLOR]
Redirect /domains /domains.php[COLOR="Red"] [L][/COLOR]
Redirect /ftsbts /ftsbts.php [COLOR="Red"][L][/COLOR]
Redirect /ftsuploadgallery /ftsuploadgallery.php[COLOR="Red"] [L][/COLOR]
Redirect /ftsclms /ftsclms.php[COLOR="Red"] [L][/COLOR]
Redirect /ftscms /ftscms.php[COLOR="Red"] [L][/COLOR]
Redirect /ftsinventorymanager /ftsinventorymanager.php[COLOR="Red"] [L][/COLOR]
Redirect /ftspl /ftspl.php [COLOR="Red"][L][/COLOR]
Redirect /ftspns /ftspns.php [COLOR="Red"][L][/COLOR]
Redirect /ftsrs /ftsrs.php [L]
Redirect /ftssafs /ftssafs.php [COLOR="Red"][L][/COLOR]
Redirect /ftssnts /ftssnts.php [COLOR="Red"][L][/COLOR]
Redirect /ftsss /ftsss.php[COLOR="Red"] [L][/COLOR]
Redirect /ftsssforum /ftsssforum.php[COLOR="Red"] [L][/COLOR]
Redirect /ftstts /ftstts.php[COLOR="Red"] [L][/COLOR]
Redirect /hosting /lhosting.php[COLOR="Red"] [L][/COLOR]
Redirect /lhosting /lhosting.php[COLOR="Red"] [L][/COLOR]
Redirect /mshosting /mshosting.php[COLOR="Red"] [L][/COLOR]
Redirect /networking /networking.php[COLOR="Red"] [L][/COLOR]
Redirect /news /news.php [COLOR="Red"][L][/COLOR]
Redirect /portfolio /portfolio.php[COLOR="Red"] [L][/COLOR]
Redirect /privacypolicy /privacypolicy.php [COLOR="Red"][L][/COLOR]
Redirect /register /register.php [COLOR="Red"][L][/COLOR]
Redirect /reseller /reseller.php [COLOR="Red"][L][/COLOR]
Redirect /seo /seo.php[COLOR="Red"] [L][/COLOR]
Redirect /sitemap /sitemap.php[COLOR="Red"] [L][/COLOR]
Redirect /services /services.php[COLOR="Red"] [L][/COLOR]
Redirect /survey /survey.php[COLOR="Red"] [L][/COLOR]
Redirect /terms /termsandconditions.php[COLOR="Red"] [L][/COLOR]
Redirect /testimonials /testimonials.php [COLOR="Red"][L][/COLOR]
Redirect /unsubscribe /unsubscribe.php[COLOR="Red"] [L][/COLOR]
Redirect /webdesign /webdesign.php [COLOR="Red"][L][/COLOR]


RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} !^www.fasttracksites.com$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\\ /index\\.php\\ HTTP/ 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^error/([^/\\.]+)/?$ error.php?error=$1 [L]
RewriteRule ^license_agreement/([^/\\.]+)/([^/\\.]+)/?$ license_agreement.php?file_requested=$1&name=$2 [L]

When viewed like this, it’s obvious that you didn’t bother to look at the mod_alias link I’d provided as there are NO flags allowed (it’ll cause the mod_alias - Redirect - syntax to fail).

Furthermore, your Redirect statements began like a warmed over RewriteRule. IF you’d read the link, you would have seen that RedirectMatch can read regex but Redirect cannot.

Regards,

DK

I actually did go through your Data Koncepts and Article links thats where I found the code for the force www. at. I did not see a section concerning mod_alias specifically so I did some searches for it. I took the code above and remove the flags from the mod_alias redirects and it causes the entire site to error out with 500.

Ok so just to verify with the Redirect I should do this:


Redirect /contact contact.php 

Do i need to worry about whether or not a visitor uses the trailing slash?

spyke01,

The first thing to learn is which is the right tool to use for any job. IMHO, you’ve pulled out the wrong tool each time:

To force www, building that code into a single PHP script will NOT do the job for the entire website. A simple “force www” mod_rewrite script will do that job nicely for the entire site (see “Article” below - it has the code).

As for your list of RewriteRules, mod_alias’s Redirect is faster and more efficient (it doesn’t have to load the regex engine). Worse yet, a webmaster would NEVER make the server test for a module on every file request! PLEASE ditch the <IfModule> wrapper as that’s there to protect noobies from bringing their site down when mod_rewrite isn’t enabled. Know it is or know it isn’t - just don’t waste server resources repeating a test it shouldn’t have to do in the first place.

Regards,

DK

I would like to give my own opinion,can you image if it is a problem of the permission?Sometimes the default permission of the files or folders cannot be changed.I think your hosting provider may inform you of this in details.

Ok so more like this then:


Options -MultiViews
RewriteEngine on

RewriteBase /

RewriteCond %{HTTP_HOST} !^www.fasttracksites.com$
Redirect /(.*)$ http://www.fasttracksites.com/$1 [R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\\ /index\\.php\\ HTTP/ 
Redirect /index\\.php$ http://www.fasttracksites.com/ [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Redirect /applications /applications.php [L]
Redirect /contact /contact.php [L]
Redirect /company /company.php [L]
Redirect /design_process /design_process.php [L]
Redirect /domains /domains.php [L]
RewriteRule ^error/([^/\\.]+)/?$ error.php?error=$1 [L]
Redirect /ftsbts /ftsbts.php [L]
Redirect /ftsuploadgallery /ftsuploadgallery.php [L]
Redirect /ftsclms /ftsclms.php [L]
Redirect /ftscms /ftscms.php [L]
Redirect /ftsinventorymanager /ftsinventorymanager.php [L]
Redirect /ftspl /ftspl.php [L]
Redirect /ftspns /ftspns.php [L]
Redirect /ftsrs /ftsrs.php [L]
Redirect /ftssafs /ftssafs.php [L]
Redirect /ftssnts /ftssnts.php [L]
Redirect /ftsss /ftsss.php [L]
Redirect /ftsssforum /ftsssforum.php [L]
Redirect /ftstts /ftstts.php [L]
Redirect /hosting /lhosting.php [L]
Redirect /lhosting /lhosting.php [L]
RewriteRule ^license_agreement/([^/\\.]+)/([^/\\.]+)/?$ license_agreement.php?file_requested=$1&name=$2 [L]
Redirect /mshosting /mshosting.php [L]
Redirect /networking /networking.php [L]
Redirect /news /news.php [L]
Redirect /portfolio /portfolio.php [L]
Redirect /privacypolicy /privacypolicy.php [L]
Redirect /register /register.php [L]
Redirect /reseller /reseller.php [L]
Redirect /seo /seo.php [L]
Redirect /sitemap /sitemap.php [L]
Redirect /services /services.php [L]
Redirect /survey /survey.php [L]
Redirect /terms /termsandconditions.php [L]
Redirect /testimonials /testimonials.php [L]
Redirect /unsubscribe /unsubscribe.php [L]
Redirect /webdesign /webdesign.php [L]

AddType x-mapp-php5 .php

ErrorDocument 400 http://www.fasttracksites.com/error.php?error=400
ErrorDocument 403 http://www.fasttracksites.com/error.php?error=403
ErrorDocument 404 http://www.fasttracksites.com/error.php?error=404
ErrorDocument 500 http://www.fasttracksites.com/error.php?error=500

NO! The redirection MUST be an absolute URL. An INTERNAL absolute URL would begin with a / and an EXTERNAL absolute URL would be the full-fledged http://yadda-yadda/contact.php.

Regards,

DK

spyke,

Okay, here’s the link to the Redirect page at apache.org. Please note that the Redirect statement does NOT use any regex at all! Therefore, no metacharacters, no anchors, no flags, just Redirect [status] URL-path URL. Anything else is likely to cause the 500 error that you’re suffering. Meaning your first three Redirects should NOT look like this:

Redirect /[COLOR="Red"](.*)$[/COLOR] http://www.fasttracksites.com/[COLOR="Red"]$1 [R=301][/COLOR]
Redirect /index[COLOR="Red"]\\[/COLOR].php[COLOR="Red"]$[/COLOR] http://www.fasttracksites.com/[COLOR="Red"] [R=301,L] [/COLOR]
Redirect /applications /applications.php[COLOR="Red"] [L][/COLOR]

I’m not sure what you want with the first one (remove it as it looks like it does NOTHING), the second and third Redirects should be okay without the red parts but I’ll leave it for you to change all the rest, too.

Tip: A test server is always a great idea to develop new code. Any 500’s there do NOT impact the production server. Go get the FREE Installation chapter of Kevin Yank’s book and pay attention to the configuration changes he suggests.

Regards,

DK

spyke,

Yes, that’s what the (.*) does “for” you with mod_rewrite: Loops! Because of the syntax (as explained), the regex and flags will cause errors, thus 500 codes.

Regards,

DK

Thanks DK,
I gave that a shot and even ripped out all the Rewrite items at the bottom but still got 500 errors even on the main domain, almost seems like I am going the wrong direction here here.

Thanks for the help though.