0

here's my website organization:
enter image description here

index.php includes header, home, and footer files:
enter image description here

How should I set .htaccess so that MyWebSite/ is the only allowed URL?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Aleks
  • 111
  • 2
  • 10

1 Answers1

1

You could try it this way. Block all php files except from localhost or server IP address.

For Apache < 2.4

<Files ~ "\.php">
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Files>

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

For Apache >= 2.4

<Files ~ "\.php">
    Require all denied
    Require ip 127.0.0.1
</Files>

<Files "index.php">
    Require all granted
</Files>

Mamp should be using Apache 2.4 so the 2nd example should work.

Panama Jack
  • 24,158
  • 10
  • 63
  • 95
  • Thanks a lot sir, it let me know that my apache is < 2.4 as well – Aleks May 26 '16 at 20:40
  • No problem glad it worked out. And technically this isn't a duplicate to the that other question as it doesn't really provide a relevant answer. – Panama Jack May 26 '16 at 20:41
  • indeed, my question was more specific, either was your answer. It will help people with the same trouble if both threads are linked. – Aleks May 26 '16 at 21:39