I’m quite(absolutely) new in mod_rewrite and trying to do ‘friendly URL’s’ but there is some problem that I can’t figured it out. So, I have categories and the url is
/pic.php?cat_id=1
After rewrite it I get this url
/pic/1
When category load there is 1 image and button ‘Next’. When I click on ‘Next’ my URL is
pic.php?cat_id=1&id=2
After rewrite
pic/1/2
And here Is the problem. When I click ‘Next’ forn next image the page is refreshed, the image is sam and the url became
pic/1/1/2
And after every ‘Next’ click put one more /1/ Here is the .htaccess that I use right now
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pic/([0-9]+)(/([0-9]+))? pic.php?cat_id=$1&line[0]=$3 [L,QSA]
RewriteRule ^pic/([0-9]+)? pic.php?cat_id=$1 [L,QSA]
And here are both links
<a href="pic/'. $res['cat_id'] .'"> <--- for selecting category
<a href="'.$cat_id.'/'.$line[0].'"> <--- next image in that category
And if I choose another category while I’m in category my URL become
pic/1/2/pic/2/ <---put other category url next to the current category
Where I’m wrong. I can gues is in my href’s but I don’t know what exactly?