我有很多的网页我的问题表示,我需要打开我的所有PHP文件,并在每个PHP页面的顶部添加一行code。
I have many pages my problem stands that I need to open all my php files and add a line of code at the top of each php page.
<?php if(!defined('no_d_a')){die('What The ... how did you get here :) ');} /* no direct access */ // rest of existing code here // ?>
问题是,我可以代替做到这一点的.htaccess文件,因为我感觉升技懒惰:)
Question is can I instead do this on a .htaccess file because I am feeling abit lazy :)
TIA
推荐答案我觉得你的希望是一种prePEND与htaccess的文件?如果是的话这里亚去:
I think what your wanting is a way to prepend the files with htaccess? If so here ya go:
另存为prepend.php
Save this as 'prepend.php'
<?php if(!defined('no_d_a')){} /* no direct access */ ?>在你的.htaccess添加:
in your .htaccess add:
<FilesMatch "\.(php)$"> php_value auto_prepend_file "/home/*******/public_html/prepend.php" </FilesMatch>
将prePEND与'prepend.php
it will prepend all .php files with 'prepend.php'
您可能需要有一些条件子句..但应该让你开始。
You may want to have some conditional clauses.. but that should get you started..
您还可以追加,而不是AUTO_ prepend_file
You can also append files with 'auto_append_file' instead of 'auto_prepend_file'
更多推荐
htaccess的帮助PHP文件
发布评论