Httaccess Rewriting URL issue: how to distinguish Listing and detail page
- by Asad kamran
I am developing an commerce site, Where users can post items in any
categories( categories can be 2 to 4 levels)
I want to generate URL for listing and details pages:
Listing page will show list of items in inner category
Detail Page will show all information for item in inner category
(Inner category means Last Category in hierarchic i.e. in
classified/autos4x4s/mitsubishi/lancer/ inner mean "lancer"
Here are the Links i want to generate
1) www.example.com/classified/autos4x4s/mitsubishi/lancer/ (for
Listing)
2)
www.example.com/classified/autos4x4s/mitsubishi/lancer/2011/3/12/lanc
er-2002-in-good-condition-14/ (for detail)
I want to redirect to ads.php if just 4 categories exist in url and to
detail.php if 6 items are passed(4 category name + 2 date and title)
I write these rules:
listing ads
RewriteRule ^(.)/(.)/(.)/(.)/?$ ads.php?c1=$1&c2=$2&c3=$3&c4=$4 [NC,L]
Detail pages
RewriteRule ^(.)/(.)/(.)/(.)/(.)/(.)/?$
detail.php?c1=$1&c2=$2&c3=$3&c4=$4&dt=$5&at=$6 [NC,L]
But all the sites page redirect to ads.php (Listing page) even home page.
I changes the rules as follow: (Even though i donot want to Use Listing and
Detail in start of url Why as i see on some site as i want::
dubai.dubizzle.com/classified/autos4x4s/mitsubishi/lancer/2011/3/12/l
ancer-2002-in-good-condition-14/)
Listing pages
RewriteRule ^Listing/(.)/(.)/(.)/(.)/?$ ads.php?c1=$1&c2=$2&c3=$3&c4=$4
[NC,L]
Detail pages
RewriteRule ^Detail/(.)/(.)/(.)/(.)/(.)/(.)/?$
detail.php?c1=$1&c2=$2&c3=$3&c4=$4&dt=$5&at=$6 [NC,L]
Now all other pages are fine, but when i pass
www.example.com/classified/autos4x4s/mitsubishi/lancer/2011/3/12/lanc
er-2002-in-good-condition-14/ it always goes to Listing page (ads.php) not to detail page.
Any help would be appreciated.