Can I make a dynamic .htaccess file?

Is it possible to create my .htaccess using php?
I would like to use php to dynamically create my htaccess file from information from the database.
This will save me from having to create a new .htaccess file when I change a bit of my code.

+3
source share
3 answers

You can read and write files with file system functions , for example:

$data = <<<EOF
RewriteEngine on
RewriteRule …
EOF;
file_put_contents('.htaccess', $data);

But it would be more flexible if you used one static rule that redirects requests to your PHP file and then does the rest.

+8
source

? . PHP, .

? , PHP , , , . -, , . ( XML, XSLT , mysql, script).

0

.htaccess PHP, script, - . ? - , , - , . , , ?

What exactly are you trying to update?

0
source

Source: https://habr.com/ru/post/1767045/


All Articles