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

137
Visualizações
htaccess rewrite url with eventual subfolder

I have urls like this:

https://mywonderfulsite.com/page

and my .htaccess rewrites it as

https://mywonderfulsite.com/index.php?source=page

The .htaccess is the following:

RewriteEngine on
RewriteBase /
RewriteRule \.(php)$ - [L]
RewriteRule ^index\.html$ - [L]
RewriteRule ^favicon\.ico$ - [L]
RewriteRule ^custom404\.html$ - [L]
RewriteRule ^custom500\.html$ - [L]
RewriteRule ^([^/]+)/?$ index.php?source=$1 [L]

This fails if the url contains a subfolder like

https://mywonderfuldomain.com/subfolder/anotherpage

that should become

https://mywonderfuldomain.com/index.php?source=/subfolder/anotherpage

I don't seem to get how to handle this situation. How to fix it?

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

0

Problem is with pattern ([^/]+) that matches anything but a /.

Use it like this:

RewriteEngine On

RewriteRule \.php$ - [L,NC]

RewriteRule ^(?:favicon\.ico|(?:index|custom500|custom404)\.html)$ - [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php?source=$0 [L,QSA]
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