Some basic questions

New to mod_rewrite? This is a good place to start.

Some basic questions

Postby Guest » Sun May 15, 2005 9:08 am

First time I've had to even really think about mod rewrite. I am working on a new site that uses a pre-written php script. It produces links like this: http://www.mydomain.com/category.php?pagenum=0&catid=19

I would like to make the original URL above into a more SEO friendly url. Let's say my top level keyword is shoes. Each catid represents a different kind of shoe (tennis shoes, loafers, high heels, etc).

Using this tool:
http://www.webmaster-toolkit.com/mod_re ... ator.shtml

I was able to produce a couple different mod rewrite rules to make the url more seo friendly.
----------------------------------------------------------
Using this mod rewrite rule:

Options +FollowSymLinks
RewriteEngine on
RewriteRule shoes(.*)-(.*)\.htm$ /category.php?pagenum=$1&catid=$2

Produces this rewritten url:
http://www.mydomain.com/shoes0-19.htm
-----------------------------------------------------------
Using this mod rewrite rule instead:

Options +FollowSymLinks
RewriteEngine on
RewriteRule category/(.*)/(.*)/(.*)/(.*)/$ /category.php?$1=$2&$3=$4

Produces this rewritten url:
http://www.mydomain.com/category/pagenum/0/catid/19/
-----------------------------------------------------------
The first choice gets my "shoes" keyword into the url, but not the type of shoe. The second choice gets no keywords at all into the url. So my guess is that the first is slightly better than the second. True? If not, why not? (My ultimate goal would be to have the url say something like http://www.mydomain.com/shoes/loafers/0-19.htm, but I guess that isn't possible, since there's no way to tell it that 19 means loafers).

My next question: How does this affect the script itself? In other words, once the page is called the script uses the pagenum=0&catid=19 to pull the appropriate information out of the database to present the information about that type of shoe. Does changing the url via mod rewrite confuse the script? Do I need to rewrite the portion of the script so it can now understand that shoes0-19.htm really means pagenum=0&catid=19 ? Or is the script itself still seeing pagenum=0&catid=19, while everyone else (users and bots) sees shoes0-19.htm ?

Thanks for the help.
Guest
 

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 45 guests

cron