Criska
Criska

Reputation: 81

.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!

Upvotes: 1

Views: 861

Answers (1)

Jon Lin
Jon Lin

Reputation: 143896

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]

Upvotes: 1

Related Questions