Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

379
Visualizações
htaccess - Allow access for my dhcp ip address only

I need to create a temporary .htaccess file on my test server so that only my public dhcp ip can access my test sites.

I have three lines in my .htaccess.

RewriteEngine On
RewriteCond expr "file('%{DOCUMENT_ROOT}/myip') != %{REMOTE_ADDR}"
RewriteRule ^(.*)$ /blackhole2.html [R,L]

The first line reads the output of my php script file written in /myip file. If the address does not match 'remote_addr' then forward to an appropiate webpage. ie: blackhole2.html

It looks like if the ip addresses match I can gain access to my test site. However, if the ip address does not match, the rewrite rule errors with 302 looping errors.

I have tried several flag delimiters etc. but have now thrown my toys out of my I.T. drawer.

What have I overlooked, or not understood what else is required. Thanks.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This triggers a redirect-loop when the IP address does not match because the redirected response to /blackhole2.html is caught by the same rule and redirected to /blackhole2.html again and again....

You need to include an exception for when /blackhole2.html is requested.

For example:

:
RewriteRule !^blackhole2\.html$ /blackhole2.html [R,L]

Or simply block the request (403 Forbidden) and don't redirect:

:
RewriteRule ^ - [F]

Although you will need to create an exception if you have a custom 403 ErrorDocument.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda