简体   繁体   English

如何允许使用htaccess访问特定文件夹?

[英]How can I allow access to a specific folder with htaccess?

I have an .htaccess file and I am trying to allow access to a sub website (within a folder) under our existing site. 我有一个.htaccess文件,并且试图允许访问我们现有网站下的子网站(在文件夹内)。

I'm using the following within my .htaccess file, but when I try to navigate to the folder that I want allowed I get a 403 error. 我在.htaccess文件中使用了以下内容,但是当我尝试导航至想要允许的文件夹时,出现403错误。

Options +ExecCGI
AddType application/x-httpd-php .php .html
AddHandler x-httpd-php5 .php .html

<Directory /teen-writers/>
Satisfy Any
Allow from all
</Directory>

I have also tried implementing this code: 我也尝试过实现以下代码:

<FilesMatch "\.(ttf|otf|eot|woff)$">
    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
    </IfModule>
</FilesMatch>

But when the above code is implemented, along with: 但是,当上述代码实现时,还有:

Options +ExecCGI
AddType application/x-httpd-php .php .html
AddHandler x-httpd-php5 .php .html 

I have access to the sub site/folder, but then one of my .html pages is no longer rendered as a .php page. 我可以访问子站点/文件夹,但随后我的.html页面之一不再呈现为.php页面。

Any suggestions? 有什么建议么?

You can't use the Directory directive inside htaccess. 您不能在htaccess中使用Directory指令。 Try putting this in an htaccess file inside teen-writers folder. 尝试将其放在teen-writers文件夹内的htaccess文件中。

Order allow,deny
Allow from all

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

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