简体   繁体   English

.htaccess拒绝除一个具有重写规则的文件以外的所有文件

[英].htaccess deny all files except one file which has a rewrite rule

actually I've a problem with my .htaccess file. 实际上,我的.htaccess文件有问题。 This is the Content of my .htaccess File: 这是我的.htaccess文件的内容:

RewriteEngine on  
RewriteRule ^put$ put.php 

Order Allow,Deny
<FilesMatch "^put\.php$">
Allow from all
</FilesMatch>

In the Folder where this file lays is also the file put.php . 在该文件所在的文件夹中,还有put.php文件。 I want to deny everything out of this folder, except put.php this file should be available at domain.com/folder/put nothing more. 我想拒绝此文件夹中的所有内容,除了put.php该文件应该可以在domain.com/folder/put上找到。 But what it actually does, is that everything is denied, also put but put.php works. 但其实际作用,是一切被拒绝,也putput.php工作。 How can I fix this? 我怎样才能解决这个问题?

Thanks in advance! 提前致谢!

Try using just mod_rewrite. 尝试仅使用mod_rewrite。 It could be that the filesmatch is denying the /put request, so mod_rewrite can't rewrite it. 可能是filesmatch拒绝了/put请求,因此mod_rewrite无法重写它。

Try: 尝试:

RewriteEngine on  
RewriteRule ^put$ put.php [L]
RewriteRule !^put(\.php)?$ - [L,F]

RewriteCond %{THE_REQUEST} /put\.php
RewriteRule ^put\.php$ - [L,F]

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

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