简体   繁体   中英

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

actually I've a problem with my .htaccess file. This is the Content of my .htaccess File:

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 . I want to deny everything out of this folder, except put.php this file should be available at domain.com/folder/put nothing more. But what it actually does, is that everything is denied, also put but put.php works. How can I fix this?

Thanks in advance!

Try using just mod_rewrite. It could be that the filesmatch is denying the /put request, so mod_rewrite can't rewrite it.

Try:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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