This article is about to explain the trick to auto append and prepend the php file using htaccess file. Surprised?
Normally all project have some files which needs be included in all files of your project. Or there can be some files which needs to included at the starting of page execution and some file which needs to be included at the end of each page.
In these cases you can write these two lines in your [code].htaccess[/code] file which will helps you for sure.
Prepend File using .htaccess
You can write below code in your .htaccess file for the same.
[cc lang=”apache”]
php_value auto_prepend_file “/real/path/to/file/file_name.php”
[/cc]
Append File using .htaccess
You can write below code in your .htaccess file for the same.
[cc lang=”apache”]
php_value auto_append_file “/real/path/to/file/file_name.php”
[/cc]
Conclusion
This trick will be useful for the file which has all your functions defined you can prepend this file and for the file like footer you can add this as a append file using this trick.
You can refer to articles related to htaccess tricks at this category, also you can subscribe to our RSS feed using your email address.
Some service providers block .htaccess calls to auto-append, generating a 500 error.
Yes true
how to enable auto_prepend_file in .htaccess