I am new to rewriting the rules and one question is that I write again for a very small API Trying to configure the rules, is there any other way to do this in any way than the things that come with me?
I have to run PHP behind it, using a type of MVC workflow where the controller, method and logic will be taken from the URI, but will represent the first supreme API key.
PHP concept:
controller-> Method (Logic)
Configuration:
space / API / {# API key again ^ / api / ([0-9 \ -] +) /? $ /api/index.php?apikey=$1final; # Repeat API key and controller ^ / api / ([0- 9 \ -] +) / ([0-9-a-zA-Z \ -] +) /? $ /api/index.php?apikey=$1& Controller = $ 2 last; #Reading the passing API key, controller and method ^ / API / ([0-9 \ -] +) / ([0-9A-GA-Z \)] + / ((select | insert | delete) +) /? $ /api/index.php?apikey=$1&controller=$2&method=$3 final; Rewrite # API key, controller, method, and arguments ^ / api / ([0-9 \ -] +) / ([0-9a-zA-Z \ -] +) / ((select | insert | Delete) +) / ([0-9 \ -] +) /? $ /api/index.php?apikey=$1&controller=$2&method=$3&argument=$4 final; }
Thank you in advance,
If you do a rewrite Define rules for every API request, you will end up with a dirty, hard-to-read NGNX configuration file. In addition, you still have to define all the same root in PHP.
Therefore, in my opinion this is just a general purpose rewriting, such as:
space / API / {# rewrite the API requests. ^ / Api / (. *) /? $ /api/index.php?uri=$1 Last; }
and then handle all logic in index.php - parse $ _REQUEST ['Yuri'] and according to the route. If you are redirecting everything to the same file, then why apply the same logic twice?
No comments:
Post a Comment