djskinner
djskinner

Reputation: 8125

Deny access to all files not caught by a mod_rewrite rule

Id like to deny access to everything, except /json-rpc, which should be redirected to /json-rpc.php. My current configuration is:

Options -Indexes

Order Deny,Allow 
Deny from All 

<Files "json-rpc"> 
     Order Deny,Allow 
     Allow from All
</Files>

<Files "json-rpc.php"> 
     Order Deny,Allow 
     Allow from All
</Files>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^json-rpc$ json-rpc.php [NC,L]
</IfModule>

The problem with this is that it allows access to /json-rpc.php directly. How do I make it so that /json-rpc is the ONLY resource available?

Upvotes: 0

Views: 656

Answers (1)

Jon Lin
Jon Lin

Reputation: 143896

Include this rule inside your <IfModule mod_rewrite.c> block:

RewriteCond %{THE_REQUEST} json-rpc\.php
RewriteRule ^ - [L,F]

This forbids requests directly for json-rpc.php.

Upvotes: 1

Related Questions