
¿Cómo puedo eliminar el .html de una URL con argumento?
p.ej: http://www.domain.com/somepage.html?argument=whole&bunch=a-lot
a:
http://www.domain.com/somepage?argument=whole&bunch=a-lot
Yo he tratado
location / {
index index.html index.php;
rewrite ^\.html(.*)$ $1 last;
try_files $uri $uri/ @handler;
expires 30d; ## Assume all files are cachable
}
y un montón de otras sugerencias, pero parece que no puedo hacerlo funcionar...
tnx
Respuesta1
Modifica tu configuración así:
# rewrite html extensions
rewrite ^(/.+)\.html$ $scheme://$host$1 permanent;
location / {
index index.html index.php;
# this way nginx first tries to serve the file as an .html although it doesn't have the extension
try_files $uri.html $uri $uri/ @handler;
}
Por supuesto, puede agregar cualquier configuración de caché, etc., pero esto debería ser suficiente para eliminar la parte .html.