Reputation: 2008
I am using .htaccess file to achieve clean urls ,But issue is , I am unable to get 2nd parameter.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)$ result-by-city.php?city=$1
RewriteRule ^\/(searedness)([0-9]+)(.*)-gu([0-9]+)\/(.*)$ ?searedness$2=$4&%{QUERY_STRING}[L]
</IfModule>
If I add second parameter like this
RewriteRule ^([a-zA-Z0-9]+)$ result-by-city.php?city=$1&location=$2
then , page goes 404
http://example.com/delhi/noida --> returns 404
http://example.com/delhi/ --> working fine with below rule only
RewriteRule ^([a-zA-Z0-9]+)$ result-by-city.php?city=$1
Upvotes: 1
Views: 907
Reputation: 785196
You may use this rule for :city/location/speciality
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)(?:/([^/]+)(?:/([^/]+))?)?/?$ page.php?city=$1&location=$2&speciality=$3 [L,QSA]
This single rule will support all of these URILs:
example.com/delhi
example.com/delhi/noida
example.com/delhi/noida/dentist
Upvotes: 2