简体   繁体   中英

.htaccess - Deny from all except index.php and current directory ./

.htaccess

'Deny from all' all files except index.php and current directory./

Hi all, I'm trying for too much time a stupid thing that had to work but i don't know how to do it.

Order Deny,Allow
Deny from all
Allow from 127.0.0.1
<Files /index.php>
    Order Allow,Deny
    Allow from all
</Files>

How to do it? Plz

Because if I search THIS URL from my browser --> https://hostname.com/403dir/ it gives me 403 error and I don't want it.

With your shown samples, could you please try following. Make sure your htaccess file is in your root path(besides 403dir path NOT inside 403dir).

Please make sure to clear your browser cache before testing your URLs.

RewriteEngine ON
RewriteCond %{REQUEST_URI} !^/403dir/?$ [NC]
RewriteCond %{REQUEST_URI} !index\.php$ [NC]
RewriteRule ^ - [F,L]


OR use a single condition itself as follows, make sure either you use above solution OR following solution only at a time please.

RewriteEngine ON
RewriteCond %{REQUEST_URI} !(^/403dir|index\.php$) [NC]
RewriteRule ^ - [F,L]

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