views:

812

answers:

2

I've been working my way through setting up rewrite rules so I can have shorter and nicer URLs, and I have a very ajaxy site.

I've got rewrite rules working on the server, and the pages load with the nice new urls, but it appears all the ajax is now broken. Firefox tells me its a 500 error.

Trying to load the page directly, I don't get a '500 Error' page, but it does return '3738', though I have no idea what this means.

So I checked the apache logs, and sure enough

GET /processes/format.php?output=queries HTTP/1.1" 500 33

the problem is, i have no idea why this is broken. The page exists, so I'm guessing it is an issue with rewriting urls?

My rewrite rule looks like this

RewriteEngine On
    RewriteCond %{REQUEST_URI} !\.(php|html|css|js|gif|png|jpe?g)$
    RewriteRule (.*)$ /index.php [L]

-----------------edited 1------------------ So I've got the error log, and it looks like the error is in the rewriterule not recognizing

 init rewrite engine with requested uri /processes/format.php 
applying pattern '(.*)$' to uri '/processes/format.php'
 RewriteCond: input='/processes/format.php' pattern='!.(php|html|css|js|gif|png|jpe?g)$' => not-matched pass through /processes/format.php 

So I'm thinking this is an error with the rewrite rule, as the !.php should have been matched, unless I'm reading the log wrong.

----------------edit 2 ------------------ Looks like this may be a 2 part error. Part 1 javascript is loading a 500 error Part 2 the page isn't outputting the content. I've thrown a few echo's into the page, and the URL is retrievable. Not sure where that 3738 is coming from.

+2  A: 

Some steps that might help you pin the error:

  • Have you tried the format.php page without using the js?
  • Try to turn on more verbose debugging on the rewriting:

    RewriteLog /var/log/apache2/rewrite.log

    RewriteLogLevel 9

RewriteLogLevel 9 is extremely verbose, and not to be used in production

More info about rewritelog: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteLog

Torandi
Yes, I did try to get the page without the JS (sorry, I edited my entry and somehow removed that, I'll put it back.
pedalpete
I have turned on that logfile and put the output into the first comment above.
pedalpete
A: 

CRAZY!!! Still not sure how/why this is happening on my test server, and very concerned about how it will progress, but the code now works on prod & test.

I think the 500 error was very misleading. There wasn't an error, but the page wasn't returning the content that it should have.

Here's what was happening.

The link I was trying to get was format.php?output=queries

Now, with PHP, i should have to get the variable $_GET['output'], but I use the same page as an include, so I use this

if(!isset($output)){
$ouput=@$_GET['output'];
}

For some reason on my test server output was being set, even when the page is being retrieved in a new window. How is that possible? It's only in the URL, how does PHP know how to assign it?

Anyway, I know that the page that uses format.php has a variable that I don't use anywhere else, so I check for that variable now. Problem fixed.

Once I did that, the page loads, and firebug shows nothing. The question is now, why did Firebug interpret a near empty page as a 500 error?

pedalpete