Get exclusive CAP network offers from top brands

View CAP Offers

Reply To: Need help with mod-rewrite

[bsa_pro_ad_space id=2]
#702110
Anonymous
Inactive
ewhitaker wrote:
Without the forward slash in front of “helpful_links” how would the script know where to find the file?If helpful_links.php is in the main root directory (e.g. yoursite.com/helpful_links.php), then you don’t need the forward slash. (I don’t find it necessary, anyway. I don’t remember if the / messes up the rule or not… you could try it both ways, I guess).

And since each cid number is assigned a category, I was hoping to find out if there was a way to write the code to reflect this.

For example:
cid 10 = poker
cid 11 = casino

Yeah, I know what you mean…. Somewhere along the way, the query that calls for the information in your database needs to get the data associated with cid10, cid11, etc… If each cid is assigned to a unique category name, you can make this work by calling for the category name (instead of the cid number) in the query.

For example, change

$query = “SELECT * FROM tablename WHERE cid = 10”;

to

$query = “SELECT * FROM tablename WHERE categoryname = ‘poker'”;

(be careful to include the single and double quotes in the right places)

If the category name is contained in the URL, first you could “GET” the category name and then insert it into the new query, like this:

$cat_name=$_GET;

$query = “SELECT * FROM tablename WHERE categoryname = ‘$cat_name'”;

The URL where it retrieves the cid from would look like this, for example:

yoursite.com/helpful_links/2/poker.php

which, from the .htaccess file, would be rewritten to look like this behind the scenes:

yoursite.com/helpful_links.php?pg=2&cid=poker

Hopefully this works out for you. Good luck! :D