Web Hosting Talk







View Full Version : search friendly urls with apache mod rewrite - slow things down?


grabmail
01-01-2006, 05:38 PM
does it increase the load and slows down the server?

emevas1977
01-02-2006, 01:43 AM
grabmail,
I don't think I understand what your are asking?

if you want search engine friendly urls and r programming in php and these pages are being create from a database you can do what I did at http://www.oldsaybrookchamber.com were the pages are published out to html. This keeps down the server load from having to communicate with the database.

tamasrepus
01-02-2006, 05:42 AM
Yes, using regular expressions for mapping URLs with mod_rewrite does increase server load and may slow it down. Unless you have a very large site, however, the increase is probably negligible.

quazi
01-02-2006, 06:58 AM
why use mod rewrite, when you can make folders and index.php pages on the fly using php. A little on the advanced and tedious side, but the effects ensure that search engines know it is a real folder.

example site: http://www.gotlyric.com/

*gotlyric.com does not use mod rewrite, those are real folders.

grabmail
01-02-2006, 07:44 AM
ok. let's disregard the mod rewrite for the moment.

what is the best way to implement a search engine friendly url system?

i check google and most sites suggest mod rewrite.

quazi's idea seems interesting. can you elaborate on this?

i want something like this.

instead of

domain.com/product.php?pid=2

i want

domain.com/product/2

quazi
01-02-2006, 07:52 AM
hrm, basicly. what you do is write a script to handle the pagetypes you need. in that script you look for an id or name pointer defined in the folder loaded.

say a user visits

www.gotlyric.com/Artist/A/

in that folder is a file that contains the following.

<?php
$GLOBALS[A9_LikeLetter] = "A";
include_once("../../artist.php");
?>

.. If you wish to get more advanced with it, you can have php create those index.php pages by itself. This requires a 404 error handler, and tons and tons of error checking and verification. I do not recomend using my idea/concept unless you are highly skilled in php. The only downside in using my method, is the larger your website, the more folders that would be made. Gotlyric has a few hundred thousand folders created on the fly from php. If your code is not 100% secure and accurate your site will come crashing down using this method.

Your best bet will be to use mod-rewrite, as it is easier to setup and many programers know about it and could help you with it. It does slow down the site a bit, however you will not have to worry about folder creation on the fly.

grabmail
01-02-2006, 08:25 AM
i read another method using PHP PATH_INFO.

is that faster than mod_rewrite?

quazi
01-02-2006, 08:40 AM
i read another method using PHP PATH_INFO.

is that faster than mod_rewrite?

If you are reffering to the URI hack, where you do www.domain.com/?/folder/something/ then yes it is faster, however search engines do not like that link format, and your search engine listing rank will plumit.

NateD
01-02-2006, 09:43 AM
Learn how to use mod_rewrite - it will make your website much more search-engine friendly which will result in a better ranking for your website.

Unless your site experiences heavy traffic 24/7, the performance hit will be minimal.

sasha
01-02-2006, 11:33 AM
mod_rewrite will slow down site when used in htaccess file opposed to it being used in httpd.conf. Fortunately that slowdown is not too obvious.

I do not like solution quazi is describing. There are too many files involved and the login is scattered all around the place. Personally I like/use mod_rewrite a lot. Here is simple example:

www.hfvt.com/content/page/product_details/pid/18/Bluetooth__CK3300_GPS.html

That URL is rewritten to:
www.hfvt.com/index.php?page=product_details&pid=18

This way all site logic is kept in the single place: index.php.

quazi
01-02-2006, 12:02 PM
Sasha is right, you should use mod-rewrite.
My method is only good if you have excessive traffic, more then 10k per day, and a server to spare.

Oras
01-02-2006, 03:10 PM
Also quazi method make the site hard to upgrade with large amount of files in many folders!! also saving this links will take larger space than it should take.

tamasrepus
01-02-2006, 06:17 PM
I don't see what is so bad about quazi's suggestion to use PHP_PATH_INFO?

It does not use regular expressions, and logic can be hardcoded in a PHP script--it can be faster than mod_rewrite. The downside, it requires (relatively) heavy modification to your original script.

mod_rewrite is not the fastest nor necessarily the "best" but it is no doubt the easiest. A few lines added to your Apache configuration and a little/none modification to your original scripts and you'll be up and running.