Answer the question
In order to leave comments, you need to log in
How can I process different URLs with one script?
How can I process different URLs with one script?
Let 's say example.com/info.php , example.com/profile/index.php and example.com/admin/panel/index.php are processed by one script example.com/scrypt.php
Is it possible to solve this issue through PHP?
How to implement it through nginx/(apache) config?
Answer the question
In order to leave comments, you need to log in
Well, the simplest thing is, of course, to make a conditional construction like this in the script.php file:
<?php
if($_GET['action'] == 'profile'){
require_once($_SERVER['DOCUMENT_ROOT'].'/profile/index.php');
} elseif ($_GET['action'] == 'info') {
require_once($_SERVER['DOCUMENT_ROOT'].'/info.php');
}
?>
location / {
try_files $uri $uri/ /index.php?$query_string;
}
And of course, there is no information on this topic on the entire Internet, right?
As a rule, administration / configuration of services (Apach and Nginx are HTTP services) are separated from simple programming (and they don’t climb into the service configs for every sneeze).
So the simplest thing is to create example.com/info.php, example.com/profile/index.php and example.com/admin/panel/index.php files with only one line
<?php require($_SERVER['DOCUMENT_ROOT']."/scrypt.php"); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question