Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda