Using .htaccess to pass multiple parameters -


I am using my .htaccess to cross both ID and one mode. Currently passing an id of it and looks like this:!

  RewriteBase / RewriteCond% {RewriteEngine on current REQUEST_FILENAME} -f RewriteCond% {REQUEST_FILENAME} -d RewriteCond% {REQUEST_URI} * / ([0-9] +) /? $ Rewrite rules * /listing.php?id=%1 [L, QSA]  

The link looks like this:

  http: //www.drlistings Com / villas / stunning_180_degree_ocean_view / 4074 /  

I want to add a mode like:

  http://www.drlistings.com/villas/ Stunning_180_degree_ocean_view / 4074 / inline  

to pass

  listing.php id =% 1 & amp ;? Mode =% 2  

I have examined other posted queries but compared to what I'm doing compared to what I'm doing. The second parameter does not have to be numeric, even if it is numerical to make it easier, then I am fine with that, it may be before or after the ID parameter, I'm flexible, like:

  http://www.drlistings.com/villas/stunning_180_degree_ocean_view/inline/4074/  

Or if it was numeric then it would be a 0/1 flag position:

  http://www.drlistings.com/villas/stunning_180_degree_ocean_view/0/4074/  

Thanks!

Your initial rule might be RewriteRule RewriteCond > Take matching in, because it will be a more traditional use just to correct your existing rule, use

  RewriteCond% {REQUEST_FILENAME}! -f RewriteCond% {REQUEST_FILENAME}! -d # RewriteRule on the left of RewriteRule, match the number in $ 1. Optionally accept the ID as an alphanumeric string Can you add non-capturing group  (? :)  in which a regular capture group is nested, which will populate the mode in  $ 2  ? Ending with  is made optional and then a  /?  End has been added with permission for an alternate follower  / . 

  RewriteCond% {REQUEST_FILENAME}! -f RewriteCond% {} REQUEST_FILENAME -d RewriteRule ^ [^ /] + / ([0-9] +)! (: / ([One-Z0-9] +))? / $ /listing.php?id=$1& Mode = $ 2 [L, QSA]  

By breaking it:

  • ^ [^ /] + matches first /
  • ([0- 9] +) takes the numerical ID to $ 1 .
  • (? :)? end of ?
  • /
  • >>
  • ( matches an alphanumeric mode an optional backlash slash
  • $ < / Code> end of the string.

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -