php - apache rewrite rule with multiple parameters -


i'm new .htaccess things, i'm trying make that.

localhost/easyapy/?tablename=%tablename% => localhost/easyapi/%tablename% localhost/easyapy/?tablename=%tablename%&action=get&id=%id% => localhost/easyapi/%tablename%/get/%id% localhost/easyapy/?tablename=%tablename%&action=delete&id=%id% => localhost/easyapi/%tablename%/delete/%id% localhost/easyapy/?tablename=%tablename%&action=update&id=%id% => localhost/easyapi/%tablename%/update/%id% localhost/easyapy/?tablename=%tablename%&action=add => localhost/easyapi/%tablename%/add 

thanks! :)

you looking that:

rewriteengine on rewriterule ^/?easyapi/(\w+)/get/(\d+)/?$    /easyapi/index.php/?tablename=$1&action=get&id=$2 [l] rewriterule ^/?easyapi/(\w+)/delete/(\d+)/?$ /easyapi/index.php/?tablename=$1&action=delete&id=$2 [l] rewriterule ^/?easyapi/(\w+)/update/(\d+)/?$ /easyapi/index.php/?tablename=$1&action=update&id=$2 [l] rewriterule ^/?easyapi/(\w+)/add/?$          /easyapi/index.php/?tablename=$1&action=add [l] rewriterule ^/?easyapi/(\w+)/?$              /easyapi/index.php/?tablename=$1 [l] 

note: assumes id's of numeric type.

that rule set work likewise in dynamic configuration files or in http servers host configuration.

keep in mind exposing database in such transparent manner major security issue. , no, fact meant used "locally" not reply that. not @ all.


and general hint: should prefer place such rules inside http servers host configuration instead of using dynamic configuration files (".htaccess"). files notoriously error prone, hard debug , slow down server. provided last option situations not have control on host configuration (read: cheap hosting service providers) or if have application relies on writing own rewrite rules (which obvious security nightmare).


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -