htaccess的帮助PHP文件 [英] htaccess assisting a php file

查看:102
本文介绍了htaccess的帮助PHP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多的网页我的问题表示,我需要打开我的所有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文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆