Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm using the following .htaccess file in one of my subdirectories on my server:

Options +FollowSymlinks
RewriteEngine on
RewriteRule (.*)\.png generate.php?userid=$1

My non-production environment handled the above just fine without a hitch.

However, when implemented on my live production environment and accessed, the server load goes through the roof and no webpages are loaded until the process is killed (I don't actually know the process, the other administrator just does it for me.)

So, is it my production environment that is set up incorrectly or is it that my code is sloppy/incorrect?

share|improve this question
1  
What does generate.php do? –  paulmorriss Jun 3 '11 at 8:03
add comment

2 Answers

There is probably not enough information to rule out all possibilities but I would try two things:

  • Add the [L] flag whichs stands for last rule which will avoid the recursive evaluation.
  • Define your paths more. Particularly the target path could start with a /. This will avoid errors in case you do not use the same paths on both systems. I would also use the ^ and $ special chars to make the rule more specific. Something like:

RewriteRule ^(*.).png$ /generate.php?userid=$1 [L]

share|improve this answer
add comment

You must have done detective work to suspect that this rewrite is the cause, but do you see any similar server issues when you load the URL directly? i.e. when you go to

http://www.example.com/generate.php?userid=example

Look for other differences between your environments:

  • like file permissions
  • php configurations
  • what graphics libraries are installed and preferred
  • Enable rewritelog at the apache conf/vhost level and compare

You have more info than we do, but if the exact .htaccess and assuming exact apache version/config, looking at the rewrite to behave differently on live than production seems.. unlikely?

share|improve this answer
    
No, loading the page directly does not reproduce the problem. –  esqew Jun 3 '11 at 19:13
    
Well, that's good info as it would really seem to knock it back to apache as you suggest. Have you been able to check out/perform the other suggestions for finding differences in your dev vs live? –  Gavin C Jun 4 '11 at 16:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.