mod_rewrite help

alus1onZ

Regular Member
Joined
Apr 30, 2009
Messages
364
Reaction score
212
Hi there! I have a problem with the mod_rewrite that I can't solve, so I'm asking for help.

I want to make the dinamic urls:

Code:
http://domain.com/showcat.php?cat=3D&page=2 
http://domain.com/showcat.php?cat=3D&subcat=Main&page=2

To look something like this:
Code:
http://domain/cat/subcat/page/2/
http://domain/cat/page/2/

Here is the .htaccess that comes with the script it might help.

Code:
Options +FollowSymLinks
RewriteEngine On

RewriteRule ^top/page/(.*)/$ http://domain.com/top.php?page=$1 [L]

RewriteRule ^latest/page/(.*)/$ http://domain.com/latest.php?page=$1 [L]

RewriteRule ^(.*)/(.*)/(.*).html$ http://domain.com/show.php?cat=$1&sub_cat=$2&img=$3 [L]

RewriteRule ^(.*)/(.*)/$ http://domain.com/showcat.php?cat=$1&subcat=$2 [L]

RewriteRule ^(.*)/$ http://domain.com/showcat.php?cat=$1 [L]

RewriteRule ^most-rated.html$ http://domain.com/showmost.php?type=1 [L]
RewriteRule ^most-clicked.html$ http://domain.com/showmost.php?type=2 [L]
RewriteRule ^most-downloaded.html$ http://domain.com/showmost.php?type=3 [L]
RewriteRule ^most-Searched.html$ http://domain.com/showmost.php?type=4 [L]

Thanks in advance!
 
Please, someone ... :crazy:
 
Lord's example will work, but you should be as specific as possible in your rewrite rules to avoid getting wrong types of data in your PHP scripts. So modify it further to this:

Code:
RewriteEngine On
RewriteRule ^([a-z0-9]+)/([0-9]+)/$ /showcat.php?cat=$1&page=$2 [L]
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/([0-9]+)/$ /showcat.php?cat=$1&subcat=$2&page=$3 [L]

This will ensure that $_GET['cat'], $_GET['subcat'], and $_GET['page'] will all contain at least one character, the categories will consist only of lowercase letters and numbers, and your page will only be digits.
 
Nope, still don't work neither with funinlee's suggestion :(
 
Back
Top