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

217
Vistas
add .html to url but results 404 not found

Read this and bababa but sadly none of them can direct me how to debug.

I am trying to redirect below url https://example.com/hello to https://example.com/hello.html

Here is how I did

First

vim /etc/apache2/apache2.conf, set AllowOverride All in <Directory /var/www/>

Now is

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

Second

sudo service apache2 restart

Third

Create .htaccess in public_html and below code

<IfModule mod_rewrite.c>
  
Options FollowSymLinks

RewriteEngine On
RewriteCond %{REQUEST_URI} !^.*\.html$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ %{REQUEST_FILENAME}.html

</IfModule>

But still return 404 not found like below.

enter image description here

Any suggestion or any parts I am missing to config apache? Thanks


------ANSWER------

Missed the configuration for mod_rewrite. Can check this post

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You are adding .html at the end of %{REQUEST_FILENAME} which will aways cause a 404 since %{REQUEST_FILENAME} represents full filesystem path not the URI path.

You should use this rule:

RewriteEngine On

RewriteCond %{REQUEST_URI} !\.html$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . %{REQUEST_URI}.html [L]

or even better:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [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