1
votes

i am trying in my .htaccess to allow access only from local network to all site and allow access from external network just one subfolder to read some php

docroot - var/wwww/html

.htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.site\.com\:8080$ 
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

var/www/html/site

.htaccess

order deny, allow
deny from all
allow from 172.16.1.*

var/www/html/site/public

.htaccess

allow from all

from lan, docroot and all site is ok

from external, docroot is ok but site and public folder i get "Internal Server Error"

could you help me how to solve this problem? thanks!!

ps: sorry for my english

1

1 Answers

0
votes

You are getting "Internal Server Error" because your RewriteCond is wrong and your rules are constantly looping.

This condition is the problem:

RewriteCond %{HTTP_HOST} !^www\.site\.com\:8080$

Since %{HTTP_HOST} only matches host name without port number.

You can have it this way:

RewriteCond %{HTTP_HOST} !^www\.site\.com$