Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

my htaccess rule goes to page and not id

i have a rental property website and i am migrating to a new site. i have problem with my rules from apache.

eg: /FL/Miami/2/ /CA/San-Diego/41/

i want to be able to display dynamically a page based on the url

rewriterule ^([a-z]+)/$ index.php?state=$1&city=&mode=list
rewriterule ^([a-z]+)/([a-z]+)/$ index.php?state=$1&city=$2&mode=list
rewriterule ^([a-z]+)/([a-z]+)/([0-9]+)/$ index.php?state=$1&city=$2&id=$3

so i see all the list for each state or list for each state/city

now my problem is when i try to see page 2, i get the ID instead

is there a magic way to fix this?

like image 471
Joanna Lancaster Avatar asked Dec 22 '11 02:12

Joanna Lancaster


1 Answers

Here's what will work for you (put this in your .htaccess in your document root):

RewriteEngine On
RewriteBase /

rewriterule ^([a-z]+)/?$ index.php?state=$1&city=&mode=list [NC,L,QSA]
rewriterule ^([a-z]+)/([a-z0-9_\-]+)/?$ index.php?state=$1&city=$2&mode=list [NC,L,QSA]
rewriterule ^([a-z]+)/([a-z0-9_\-]+)/([0-9]+)/?$ index.php?state=$1&city=$2&pagenum=$3&mode=page [NC,L,QSA]
rewriterule ^([a-z]+)/([a-z0-9_\-]+)/([0-9]+)/([a-z0-9_\-]+)/?$ index.php?state=$1&city=$2&id=$3&mode=view [NC,L,QSA]

So:

/california/san-diego/2 or /california/san-diego/2/ will to go page 2

/FL/Miami/2/home-house-test or /FL/Miami/2/home-house-test/ will to to the property page

like image 164
Book Of Zeus Avatar answered Sep 30 '22 12:09

Book Of Zeus