Forum Moderators: coopster

Message Too Old, No Replies

Using mod_rewrite and basic cms

Can I do this?

         

hdpt00

12:14 pm on Apr 14, 2004 (gmt 0)



I am writing a CMS for my website right now and in each file I send a call to my db to add a +1 to a certain element for that site (in essence a basic hit tracker for each site). This is used to tally the most viewed articles for the day (which it calculates every night). Should I used the same db to count these hits as I do to store the cms content or since that db will most likely get huge with content, should I make my own tracking db. Also, since each page needs to have that call to the db, can I use mod_rewrite if it originally had a URL like www.domain.com/view.php?c=directory/use to something like wwww.domain.com/directory/user.html and rename it with .html extension even with the dynamic call to the db every time or does it have to be named with a .php since it calls the db?

Also, since this site will eventually be getting a lot of visitors (hopefully 100K impressions/day) is this method of wring the db every time someone enters a page going to be way too efficient? Should I go about this another way?

Thanks,
Brandon

seomike2003

3:19 pm on Apr 14, 2004 (gmt 0)



Just make a tracking table in the same DB. It would only need 2 columns IP ¦ count at it's bare minimum

Cookie users as they come in. make the value their ip. Then all you have to do is write a script that says if there's a cookie UPDATE tracking_table SET count ='#' WHERE ip='$cookie_value'. Of course you'll probably make it more elaborate than this. Cookies will take care of your AOL users that swithc ip's every 3-4 pages because of the aol proxy servers (along with a hand full of other ISPs)

If you're going to use a mod it's fairly simple to do on apache and in IIS.

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/user.html view.php?c=$1

all this is saying is start at the first "/" then between the first "/" and "/user.html" is our variable that will be inserted where the $1 is. So the php engine will process the static because the mod translates it to view.php?c=directory. Bingo you're done. Now if you're going to do more elaborate mod's you'll need to learn rewrite conditions but there's alot of documents out there that explain it.

As for writting to the db for every page. I wouldn't worry about it too much as long as you keep your sql statements as chopped down as possible. basically don't do this "SELECT *..." from a table that has 20 columns when all you need is 2 columns. etc etc.

Now mods can choke a server up so make sure your host has a lot of resources :)