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

182
Visualizações
RewriteRule not capturing backreference

I have a RewriteRule in an .htaccess file but am not able to make it work correctly:

RewriteRule ^(?!(redirect-build)) redirect-build/index.php?url=$1

The backreference $1 isn't captured and Apache rewrites the URL parameter with no value in it. Here is a snippet of the log file:

[Fri Mar 13 13:46:26.254929 2020] [rewrite:trace2] [pid 10612:tid 1344] mod_rewrite.c(477): [client 127.0.0.1:58838] 127.0.0.1 - - [domain/sid#1c4a1bda5b0][rid#1c4a2df8180/initial] [perdir D:/document-root/path/to/directory/] rewrite 'zalety-jablek' -> 'redirect-build/index.php?url='
[Fri Mar 13 13:46:26.254929 2020] [rewrite:trace3] [pid 10612:tid 1344] mod_rewrite.c(477): [client 127.0.0.1:58838] 127.0.0.1 - - [domain/sid#1c4a1bda5b0][rid#1c4a2df8180/initial] split uri=redirect-build/index.php?url= -> uri=redirect-build/index.php, args=url=

Is there any solution to it?

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

0

Example: example.com/some-path should resolve to: example.com/redirect-build/index.php?url=some-path

In that case you need to adjust your RewriteRule pattern to allow it to match & capture value like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ redirect-build/index.php?url=$1 [L,QSA,NC]
  • ([\w-]+) is capture group to match and capture 1+ of any word character or a hyphen
  • RewriteCond is used to skip existing files and directories from this rewrite
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