M
M
mozzart_live2019-05-14 13:05:24
PHP
mozzart_live, 2019-05-14 13:05:24

How to replace one php script with another without changing DOCUMENT_ROOT?

Good afternoon gurus!
There is a task, I ask for help in solving.
Bundle of nginx + apache. The user calls domain.ru/test.php
in the address bar , which contains a bunch of different code using the __DIR__, __FILE__ constants, globals and include-constructs. It is necessary in any way to replace the source code with another file that lies in a directory other than DOCUMENT_ROOT. You can edit apache and nginx configs, but adding\modifying files in the directory serving the domain.ru domain is prohibited.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Korobkov, 2019-05-14
@BorisKorobkov

Specify the required DOCUMENT_ROOT in the Apache/Nginx config for this site.
If you then need the source file, then in the new script, do the necessary actions, then chdir () and require () the source file.

S
Stalker_RED, 2019-05-14
@Stalker_RED

RewriteEngine On
RewriteRule ^test\.php$  path/to/foo.php [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question