Reputation: 4835
I am having more than 9 params in my url to be mapped into particular php file. Url is
and my htaccess rule is
RewriteRule ^USA/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ search.php?counrty=USA&state=$1&gender=$2&r_city=$3&r_mstatus=$4&r_religion=$5&r_ethnicity=$6&r_cast=$7&r_profession=$8&r_education=$9&sort_by=$10 [NC]
It is not working
Can please anybody sort out this issue? I need proper regex rule and URL
Upvotes: 1
Views: 825
Reputation: 46650
Creating such rule is restricted and bad practice & even worse that your passing the parameters to a search script; As your script progresses your most likely going to want other parameters passed other then USA, meaning your need a new rewrite for each route.
Really you should pass the entire url to your php script to handle the route.
RewriteEngine On
Options -Indexes
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^search/(.*)$ search.php?route=$1 [L,QSA]
This way you can explode('/',$_GET['route'])
within your script, giving you an array of all your route parameters.
Upvotes: 6
Reputation: 5271
Like Gumbo says, just send the whole lot to the page and process:
$segments = explode('/', $_SERVER['REQUEST_URI']);
list($country, $state, $gender, [etc etc.]) = $segments;
Upvotes: 3