When using URL rewriting for beautification, are there any thoughts on whether to do your content calculations in a PHP script or to hard code it into the .htaccess file?
For instance, WP adds the simple rule to the .htaccess file
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Which directs everything to the index.php page. Then it has a PHP script (canonical.php) parse the $_SERVER['REQUEST_URI'] to then figure out what content to actually pull up.
Instead of using PHP to handle all of this, it could be entered directly into the .htaccess file passing the query items from the URL, similar to:
RewriteRule ^products/([0-9][0-9])/$ /productinfo.php?prodID=$1
Does anyone know the advantages/disadvantages of the two methods? I'm thinking that the PHP method offers a bit more flexibility, but I may be wrong. I have no idea of which has more overhead though.
My opinion is that PHP handling is much better. The only possible minus is that it could be slower, but not so much, in overall page generation time you won't notice any difference. But the disadvantages are:
So it's definitely better to handle these by PHP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With