Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed Oct 27, 2010 1:57 am 
Offline
Senior Member

Joined: Wed Jul 21, 2010 8:04 pm
Posts: 119
I currently have a Ubuntu 10.04 server with Apache, PHP, and MySQL. I'm using it to host, among other things, a blog with a custom CMS. I've been using .htaccess (generated by the CMS when new blog posts are added) and mod_rewrite to create SEO friendly URLs for the blog posts.

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.


Top
   
 Post subject:
PostPosted: Wed Oct 27, 2010 10:34 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Yes .htaccess can cause things to slow down, since it is checked on every request. Copy the rules from .htaccess to your virutal host, restart apache, and then remove the htaccess.

mod_rewrite is still the best way (as far as I know) to do seo friendly urls.


Top
   
 Post subject:
PostPosted: Wed Oct 27, 2010 10:46 am 
Offline
Junior Member

Joined: Wed Oct 06, 2010 2:41 pm
Posts: 20
Caveat: I'm not really an expert in Apache tweaking, so take my advice with a grain of salt.

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, then you should be able to speed up the handling of requests. RewriteMap goes in your server or virtual host config, and it's smart enough to cache the mapping file until the timestamp changes. Just tweak your CMS to update the map file instead of the .htaccess file, and then use a simple RewriteRule that relies on the map to do the post title -> post id conversion.


Top
   
 Post subject:
PostPosted: Wed Oct 27, 2010 3:08 pm 
Offline
Senior Member

Joined: Wed Jul 21, 2010 8:04 pm
Posts: 119
Thanks for the suggestions. I'll try them out.


Top
   
 Post subject:
PostPosted: Wed Oct 27, 2010 9:30 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Erasmus Darwin wrote:
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.


Top
   
 Post subject:
PostPosted: Sat Oct 30, 2010 7:30 pm 
Offline
Senior Member

Joined: Wed Jul 21, 2010 8:04 pm
Posts: 119
Quote:
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?


Top
   
 Post subject:
PostPosted: Sat Oct 30, 2010 7:37 pm 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Well they both create a .htaccess file, so all you need to do is copy the contents of that file into the virtualhost file for that site then remove the .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).

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Sat Oct 30, 2010 9:04 pm 
Offline
Senior Member

Joined: Wed Jul 21, 2010 8:04 pm
Posts: 119
Lightbulb moment!

OK thank you! You've given me the help I need to figure out the rest! Goodbye .htaccess.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group