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

149
Visualizações
RewriteRule not working correctly for subfolders

There is a custom CMS and it has .htaccess.

CMS has external ERP system that calls php files in subfolder to make manipulations with data. Vendor has made refactoring and remove all php files and redirects all calls to index.php

In root has been written rule:

RewriteRule ^dbeS/(.*)\.php$ dbeS/index.php?id=$1 [QSA,L]

But it doesn't working now.

.htaccess works correctly, because if i'm pasting Test. inside <IfModule mod_rewrite.c>, i am receiving 500 error.

For NGINX rewrite ^/dbeS/(.*)\.php$ /dbeS/index.php?id=$1 last; - works perfectly for other customer. But this one does't want migrate from apache to nginx

Example: instead of https://example.com/dbeS/test.php has to be called https://example.com/dbeS/index.php?id=test

Rewrite in .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^templates_c/filecache/.*$ - [R=403,NC,L]
  RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ includes/sitemap.php?datei=$1 [L]
  RewriteRule ^export/((sitemap_).*\.(xml|txt)(\.gz)?)$ $1 [L]
  RewriteRule ^asset/(.*)$ includes/libs/minify/?g=$1 [QSA,L]
  RewriteRule ^static/(.*)$ templates_c/min/$1 [QSA,L]
  RewriteRule ^dbeS/(.*)\.php$ dbeS/index.php?id=$1 [QSA,L]
  RewriteRule ^robots.txt$ robots.php [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !^/favicon.ico
  RewriteRule ^. index.php [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/favicon.ico
  RewriteRule ^. favicon-default.ico [L]
</IfModule>
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

With your shown samples, attempts; please do try following htaccess Rules. Please make sure to clear your browser cache before testing your URLs.

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^templates_c/filecache/.*$ - [R=403,NC,L]
  RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ includes/sitemap.php?datei=$1 [L]
  RewriteRule ^export/((sitemap_).*\.(xml|txt)(\.gz)?)$ $1 [L]
  RewriteRule ^asset/(.*)$ includes/libs/minify/?g=$1 [QSA,L]
  RewriteRule ^static/(.*)$ templates_c/min/$1 [QSA,L]
  ## Comment following rule as index.php is NOT in dbeS.
  #####RewriteRule ^dbeS/(.*)\.php$ dbeS/index.php?id=$1 [QSA,L]
  RewriteRule ^robots.txt$ robots.php [NC,L]

  ##Newly added rule here for rewrite internal one.
  RewriteCond %{THE_REQUEST} \s/dbeS/(test)\.php\s [NC]
  RewriteRule ^  index.php?id=%1 [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !^/favicon.ico
  RewriteRule ^. index.php [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/favicon.ico
  RewriteRule ^. favicon-default.ico [L]
</IfModule>


Generic Rules: In case your test.php could be anything in name then try following rules. Make sure either use above OR following rules one at a time.

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^templates_c/filecache/.*$ - [R=403,NC,L]
  RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ includes/sitemap.php?datei=$1 [L]
  RewriteRule ^export/((sitemap_).*\.(xml|txt)(\.gz)?)$ $1 [L]
  RewriteRule ^asset/(.*)$ includes/libs/minify/?g=$1 [QSA,L]
  RewriteRule ^static/(.*)$ templates_c/min/$1 [QSA,L]
  ## Comment following rule as index.php is NOT in dbeS.
  ######RewriteRule ^dbeS/(.*)\.php$ dbeS/index.php?id=$1 [QSA,L]
  RewriteRule ^robots.txt$ robots.php [NC,L]

  ##Newly added rule here for rewrite internal one.
  RewriteCond %{THE_REQUEST} \s/dbeS/([^.]*)\.php\s [NC]
  RewriteRule ^ index.php?id=%1 [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !^/favicon.ico
  RewriteRule ^. index.php [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/favicon.ico
  RewriteRule ^. favicon-default.ico [L]
</IfModule>
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