PHP追加和prePEND htaccess的 [英] PHP append and prepend in htaccess

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

问题描述

在我的 PHP中的每一个文件,我需要做的:

In every single one of my php files I have to do:

<?php require_once('file.php'); ?>

我一直在做一个谷歌研究,发现我可以使用的.htaccess 追加或prePEND任何PHP文件或者我需要的任何其他文件我的每一个其他文件是这样的:

I've been doing a Google research and found that I could use the .htaccess to append or prepend any php file or any other files I need in each of my other files like this:

php_value auto_prepend_file "/real/path/to/file/file.php"
php_value auto_append_file "/real/path/to/file/file.php"

我是新手,还没有发挥各地太多的的.htaccess 。另外,我阅读了的.htaccess 搞乱可以肆虐到我的网站,我还没有尝试过了。

I'm a novice and have not yet played around too much with the .htaccess. Also, I've read that messing with .htaccess can wreak havoc to my website, I haven't tried it out.

在这里我的问题是这样的。我也有我的应用程序jQuery的文件,如果的.htaccess 将要追加/ prePEND的为file.php 中的每一个文件,甚至没有尝试它,我知道这是怎么回事,包括我的样式,我的日志文件等有没有办法使排除的文件,我不想让文件。 PHP 来追加/ prepended?

My question here is this. I also have jQuery files in my application, if the .htaccess is going to append/prepend the file.php in each and every file, without even trying it out I know it's going to include my stylesheets, my log files, etc. Is there a way make exclusions to files where I don't want file.php to be appended/prepended?

推荐答案

可以在特定的文件夹禁用它。 <一href="http://stackoverflow.com/questions/1788088/how-can-i-disable-auto-$p$ppend-in-specific-folders-using-htaccess">How我可以禁用AUTO_ prePEND特定文件夹中使用htaccess的?

you can disable it in specific folders. How can I disable auto_prepend in specific folders using htaccess?

如果您希望有条件地禁止它在某些文件,你可以在你的append.php条件语句它不会回不管它是什么,它​​一般不会,如果文件名匹配特定的条件 您可以使用 __ 文件的__ 指令来获取当前文件,你可以有一个条件检查

If you want to conditionally disable it in certain files, you can have a conditional statement in your append.php where it doesn't echo whatever it is that it normally does, if the filename matches a certain condition You can use __FILE__ directive to get the current file, and you can have a condition check

<?php
if(__FILE__!="..yourfile..")
{
?>

<link rel="stylesheet" href="...">
...

<?php
}
?>

这篇关于PHP追加和prePEND htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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