如何设置PHP包括通过htaccess的路径?路径、如何设置、PHP、htaccess

2023-09-02 00:51:45 作者:不良少年i

我想设置PHP的include路径到另一个目录。我试图把这个在.htaccess文件,但没有奏效。我唯一​​看到的是包括路径的我在httpd.conf设置,但不是一个我试图添加。

I want to set the PHP include path to another directory. I tried putting this in an .htaccess file, but that didn't work. The only thing I see is the include path's I set in httpd.conf, but not the one I tried to add.

<IfModule mod_php5.c>
php_value include_path ".:/var/www/mywebsite/"
</IfModule>

我是什么做错了吗? 我做了 a2enmod mod_php5 ,但它已经在运行,所以我想PHP5已经作为Apache模块运行。

What am I doing wrong? I did a2enmod mod_php5, but it was already running, so I suppose PHP5 is already running as Apache module.

在我的虚拟主机配置我有这样的:

In my vhost config I have this:

<Directory ~ "^/var/www/.*">
        AllowOverride All
        Options FollowSymLinks -Indexes -MultiViews
        php_value include_path ".:./include:./.include/:/var/www/.include/:/var/www/"
</Directory>

更多信息(的phpinfo()):

Loaded Modules  core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_auth_mysql mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_status

include_path    .:./include:./.include/:/var/www/.include/:/var/www/    .:/usr/share/php:/usr/share/pear

问候, 凯文

Regards, Kevin

推荐答案

的Apache必须被配置为允许设置通过的.htaccess覆盖。检查你的Apache配置文件(httpd.conf)中的一个覆盖你的目录:

Apache must be configured to allow settings to be overridden via .htaccess. Check your Apache config file (httpd.conf) for an override for your directory:

<Directory "/directory/containing/your/htaccess/file">
    AllowOverride All
</Directory>

为您的网站的虚拟主机定义中把这个。

Place this within the vhost definition for your site.

如果这是一个全球性的变化,你应该改变的include_path设置在php.ini文件,而不是使用的.htaccess。

If this is a global change, you should change the include_path setting in your php.ini file instead of using .htaccess.

这两个变化将需要一个Apache重新启动。

Both of these changes will require an Apache restart.

修改

这是从阿帕奇睿报价功能页面

假设要访问的文件名是/home/abc/public_html/abc/index.html。 服务器认为每个/,/家,/家庭/ ABC为/ home / ABC /的public_html和/ home / ABC /的public_html / ABC的顺序。在Apache的1.2,在/家庭/ ABC被认为是,正规的前pression将匹配和应用。在Apache 1.3中的常规EX pression不认为在所有的树中的那个点。它不会被认为后才一切正常和.htaccess文件已经被应用。然后定期EX pression将匹配在/ home / ABC /的public_html / ABC和应用。

"Suppose that the filename being accessed is /home/abc/public_html/abc/index.html. The server considers each of /, /home, /home/abc, /home/abc/public_html, and /home/abc/public_html/abc in that order. In Apache 1.2, when /home/abc is considered, the regular expression will match and be applied. In Apache 1.3 the regular expression isn't considered at all at that point in the tree. It won't be considered until after all normal s and .htaccess files have been applied. Then the regular expression will match on /home/abc/public_html/abc and be applied."

我认为,根据这些信息,你的 php_value include_path中语句被评估的在的.htaccess文件。如果是这样的话,你在的.htaccess使用的include_path 的值被覆盖。你可以尝试从&LT删除的include_path 线;目录&GT; 暂时以测试这个理论

I think, based on this information, that your php_value include_path statement is being evaluated after the .htaccess file. If that is the case, the value you use for include_path in the .htaccess is being overwritten. Can you try removing the include_path line from <Directory> temporarily to test this theory?