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

164
Visualizações
Remove .php extension

I have two pieces of code that removes the .php extension.

Solution 1:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Solution 2:

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]

directory is a directory

page is a page

problem with solution 1:

if you go to domain.com/directory, it is supposed to show domain.com/directory/index.php but the index.php does not appear and it just shows a 404 error page.

problem with solution 2:

if you go to domain.com/directory/page/haha-lol-blah-blah, the page domain.com/directory/page shows up, no matter what is after the page.


is there a solution for both problems?

here is what i need:

domain.com/directory -> shows the page: domain.com/directory/index.php
domain.com/directory/page -> shows the page: domain.com/directory/page.php
domain.com/directory/page/haha-lol-blah-blah -> invalid page (404)
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I believe this is working now with this code:

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php
over 4 years ago · Santiago Trujillo Relatório

0

Try it like this,

#incoming request neither a file nor a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)$ $1.php [L]
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