简体   繁体   English

尝试将htaccess的内容包含在httpd.conf中

[英]Trying to include the contents of htaccess in httpd.conf

I'm trying to include .htaccess inside httpd.conf for better performance. 我试图在httpd.conf中包含.htaccess以获得更好的性能。

I am following the instructions from the readme file here to improve site performance. 我下面自述文件中的说明这里来提高网站性能。 I took the .htaccess and placed it in my website root folder C:/xampp/htdocs/apps then inside httpd.conf I've got the code below. 我将.htaccess放在我的网站根文件夹C:/xampp/htdocs/apps然后在httpd.conf里面找到了下面的代码。 then I restarted apache. 然后我重新启动了Apache。 The problem is i don't think the .htaccess rules are being applied 问题是我不认为正在应用.htaccess规则

Is this the correct way of including .htaccess and am I including it in the correct directory? 这是包括.htaccess的正确方法吗,我是否将其包括在正确的目录中?

<Directory "C:/xampp/htdocs">

    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted

    Include C:\xampp\htdocs\apps\.htaccess

</Directory>

If you want to "include" the contents manually in directory context with the Include directive, set AllowOverride to none, otherwise you are applying the same configuration twice, once in directory and another through AllowOverride method. 如果要使用Include指令在目录上下文中手动“包含”内容,请将AllowOverride设置为none,否则将两次应用相同的配置,一次在目录中,另一次通过AllowOverride方法。

If you just want to have a .htaccess file (wouldn't figure why because you seem to have access to the main configuration), then AllowOverride all would be enough. 如果您只想拥有一个.htaccess文件(因为您似乎可以访问主配置而无法说明原因),那么AllowOverride all就足够了。

If you just want to .htaccess and make sure it is being applied you can just: 如果您只想.htaccess并确保已将其应用,则可以:

<Directory "C:/xampp/htdocs">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>

and add junk text in the .htaccess file inside this directory, if it is being read, Apache will responde with a 500 error, if it is not, chances are you are landing in another virtualhost where this directory is not set. 并在该目录内的.htaccess文件中添加垃圾文本,如果正在读取该文本,则Apache会响应500错误,如果不是,则可能是您登录了未设置此目录的另一个虚拟主机。

AllowOverride All

should already tell apache to let .htaccess override all settings. 应该已经告诉apache让.htaccess覆盖所有设置。 There is no need to include it manually i think. 我认为没有必要手动添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM