PDA

View Full Version : Suggestion on ways to make SEF urls (search engine friendly urls)


zeeshan
03-17-2005, 09:09 AM
Hi,
I'm trying to create search engine friendly urls for my site. The site structure looks something like this:

Category1
-Article1
-Article2
-Product1
-Sub-catetory
--Article3
--Article4
--Product2
--Quiz1
Category2
-Article5
-Quiz2

Basically, there are 2 levels of categories and there can be an Article, a Product or a Quiz at any level.

I need the URLs to look like folders.

mysite.com/category1/category2/article1/
mysite.com/category1/quiz2/
mysite.com/category1/category2/product2/

what i'm thinking to do is to pick the last bit from the url and search in the DB tables with the item name to identify if its an Article, a product, a quiz or just a sub category. obviously in this case i'll have to define unique names for all items and it also means that before displaying the page i'll have to query the DB 4 times jus to find out the type of item.

Could anyone suggest a better solution to this problem. I'ev read the forum but couldnt find any solution.

Many Thanks.

seomike
03-17-2005, 05:58 PM
You need a unique identifier to allow regex to know which category/folder is which. Here is a suggestion and a structure change suggestion (you really should make your folders sooooo deep;) ).

mysite.com/widgets-1/cogs-2/article-1.htm (unique identifier -)
mysite.com/widgets-1/quiz-2.htm (unique identifier - and also being 1 subfolder deep)
mysite.com/widgets-1/cogs-2/product~2.htm (unique identifier ~)

Now you know all articles are sperated with a - before the 1.htm and all products are seperated by a ~ before the 1.htm and then anything else is just a quiz :)

zeeshan
03-18-2005, 05:24 AM
Hi seomike,

First of all thanks for taking the time to reply....This seems to be a reasonable solution but my client actually wants the urls to be search engine friendly as well as easily understandable so that its easy for the user to come back to it..

Is there anyway that I could do it with just using the unique names for all types of items(categories, articles, products, quizes)..


Thanks,
Zeeshan

Aerik
04-07-2005, 07:28 AM
If you don't want to pick off the last bit and do a search (which I personally think is a fine idea, as long as you can enforce unique names), perhaps you could have a little deeper category structure to get the same effect Mike proposed: /Category1/Subcategories/Subcategory1/Articles/Article1 etc.

Aerik

seomike
04-07-2005, 06:08 PM
/Category1/Subcategories/Subcategory1/Articles/Article1

I wouldn't advise it. You'd need a huge page scores to even push a spider into a page that deep. That and the fact that deep = less important.

As far as the names being a unique identifier you can do that but I'm assuming that you'll be keeping products in 1 db table and articles in another db table. I personally use this type of structure. I make my categorie names absolutely unique and then parse them to a name that can be send as a query and of course I just nab the # and query by id.

/category-name/product-name-1.htm
/articles/article-name-1.htm
/quiz/quiz-name-1.htm

# if !-d doesn't work then uncomment these 2 lines and comment the !-d line
#RewriteCond %{REQUEST_URI} !/quiz.*
#RewriteCond %{REQUEST_URI} !/articles.*
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^([^/]+)/.*-([0-9]+)\.htm /page.php?cat=$1&id=$2 [L]

RewriteRule ^articles/.*-([0-9]+)\.htm /articles.php?id=$1 [L]

RewriteRule ^quiz/.*-([0-9]+)\.htm /quiz.php?id=$1 [L]