A Better Way to Do SEO Friendly URLs with Apache
ie
mydomain.com/blog/blog-post-title/ is actually mydomain.com/BlogPost.php?ID=(Number) but the user never knows
Since enabling .htaccess and using mod_rewrite for this, I feel like my server is a little slower.
So two questions:
1. Is that possible? Can enabling .htaccess have that much of an affect? Or am I likely imagining things?
2. (The main question): Is there a better way to do SEO friendly URLs?
I'd appreciate any advice you might have.
7 Replies
mod_rewrite is still the best way (as far as I know) to do seo friendly urls.
As obs pointed out, .htaccess files get parsed once per request. If your CMS is creating one rewrite rule per blog post, your .htaccess file is perpetually growing. Needless to say, that's a recipe for poor performance that will only get worse.
If you use mod_rewrite's RewriteMap directive
@Erasmus Darwin:
As obs pointed out, .htaccess files get parsed once per request. If your CMS is creating one rewrite rule per blog post, your .htaccess file is perpetually growing. Needless to say, that's a recipe for poor performance that will only get worse.
CMS don't usually do this, normally they just redirect back to some index file i.e. wordpress and drupal do this. It's also probably a bad idea if your apps can write to the .htaccess file since if there's a problem in the app someone could cause headaches by putting a "deny all" into it.
> normally they just redirect back to some index file i.e. wordpress and drupal do this
@obs How does Wordpress and Drupal do this without an htaccess file?
Since drupal/wordpress only create the files when asked to by the admin from the web interface you will only need to update your vhost if you ever change your settings (which most people don't).
OK thank you! You've given me the help I need to figure out the rest! Goodbye .htaccess.