i searched a lot on SOF about .htaccess and mod_rewrite and i want to performance wise which one is faster:
RewriteRule ^([a-z0-9]+)/?$ index.php?id=$1 [NC,L]
RewriteRule ^(.*)/?$ index.php?id=$1 [NC,L]
RewriteRule ^([^/]*)/?$ index.php?id=$1 [NC,L]
since the first one only accepts letters and numbers does it make it faster to execute?
When in doubt, test it out. I setup a test server running Ubuntu 2011.10 with Apache2 and used the siege load testing app to perform 3 tests. The test ran for 1 minute (or until 5000 failures) with 50 concurrent users requesting ‘/index.html’
Test #1 used the following rewrite rule configuration:
The results from siege:
Test #2 with a rewrite rule configuration:
The results:
Test #3 with the following rewrite rule:
The results: