简体   繁体   English

如何从静态 html 网站页面中删除 .html

[英]How can i remove .html from static html website pages

我有一个带有静态文件(页面)的静态网站,我希望页面的 URL 末尾不包含 .html,例如:“www.mywebsite.com/page.html”变成“www.mywebsite.html”。 com/page”当然我不能只是重定向页面,因为文件“www.mywebsite.com/page”是未知的 感谢 davance

I would recommend you use URL rewriting for your server's config file.我建议您对服务器的配置文件使用 URL 重写。 For example if you are using an apache server, you could use例如,如果您使用的是 apache 服务器,则可以使用

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

in your .htaccess file (which is the config file for your apache server.在您的 .htaccess 文件(这是您的 apache 服务器的配置文件)中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM