2

estou com um problema no htaccess

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.10 (Ubuntu) Server at localhost Port 80

htaccess:

RewriteEngine On
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


RewriteRule ^login/$ /login.php [L]

RewriteRule ^(.*)$ /zuo/index.php?acao=busca&q=$1 [L]

no log de erros aparece

AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration e$tion error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer:

quando removo RewriteRule ^login/$ /login.php [L] da certo!

1
  • Boa noite, gostaria de saber se alguma das respostas lhe ajudou, se não por favor comente o que acha que falta.
    – Reptile
    18/11/2015 às 23:01

1 Resposta 1

3

Isto ocorre porque você não adicionou uma configuração para verificar se a página já é a index.php.

No caso isto ^(.*)$ significa qualquer página deve ser direcionada

No caso acredito que você tenha tentado usar RewriteCond %{ENV:REDIRECT_STATUS} ^$ para verificar se a página já veio de um redirecionamento, mas não funcionou como o esperado.

Nota: Não use o / na frente de:

RewriteRule ^login/$ /login.php [L]
RewriteRule ^(.*)$ /zuo/index.php?acao=busca&q=$1 [L]

Use assim:

RewriteRule ^login/$ login.php [L]
RewriteRule ^(.*)$ zuo/index.php?acao=busca&q=$1 [L]

Ao invés de usar o RewriteCond você pode tentar usar um RegEx assim ^(?!(index\.php)(/.*|)|login/.*|login.php)(.*)$ que irá ignorar se começar com index.php ou index.php/path

O resultado:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^login/$ login.php [L]
RewriteRule ^(?!(zuo\/index\.php|login/.*|login.php))(.*)$ zuo/index.php?acao=busca&q=$2 [L]

Não cheguei a testar, mas a lógica é está.

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .