简体   繁体   English

父htaccess覆盖子文件夹htaccess

[英]Parent htaccess override subfolder htaccess

I have a Zend aplication that uses a hatccess and redirects everything to index.php, but now i need to use a password protect folder in one of the subfolder, but when i tried to acess the subfolder keep giving me 404 error. 我有一个Zend应用程序,它使用hatccess并将所有内容重定向到index.php,但是现在我需要在子文件夹之一中使用密码保护文件夹,但是当我尝试访问该子文件夹时,始终给我404错误。

here the zend htaccess in the public_html folder: 这是public_html文件夹中的zend htaccess:

RewriteEngine On
 RewriteRule !\.(js|txt|ico|gif|GIF|jpg|JPG|png|PNG|css|swf|pdf|xml|XML|eot|svg|ttf|woff)$   index.php
 SetEnv APPLICATION_ENV "production"

here the subfolder htaccess: 这里是子文件夹htaccess:

RewriteEngine off
AuthType Basic
AuthName "*folder*"
AuthUserFile "/home/*user*/.htpasswds/public_html/*folder*/passwd"
require valid-user

i tried to add RewriteRule ^blog/ - [L] to the public_html folder as i see in: Overwrite rewrite-rule of htaccess in parent folder 我尝试将RewriteRule ^blog/ - [L]到public_html文件夹,如下所示: 覆盖父文件夹中htaccess的重写规则

but it didnt work. 但是没有用。 what is weird is that if i take the password part of the subfolder htaccess, the "rewriteEngine off" work and i got a list of the files in that folder. 奇怪的是,如果我使用子文件夹htaccess的密码部分,则将“ rewriteEngine off”工作,然后得到该文件夹​​中文件的列表。

Obs: the server is a apache 2.2.25, so rewriteOptions InheritBefore is not a options Obs:服务器是Apache 2.2.25,因此rewriteOptions InheritBefore不是选项

Obs2: the folder and user is not like that on the actual htaccess that was just to hide the names. Obs2: 文件夹用户与实际htaccess上的文件夹用户不同 ,后者只是用来隐藏名称。

Obs3: im a noob in server configurations :) Obs3:服务器配置方面不是菜鸟:)

This usually works for me. 这通常对我有用。 Paste code in the parent htacesss underneath your RewriteRule 将代码粘贴到RewriteRule下的父级处理中

RewriteRule ^(blog)($|/) - [PT,L]

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

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