打开没有 .html 的 HTML 文件?

Open HTML file without .html?

我使用网络空间并在网络空间上有一些 html 文件。例如 XY.html 文件。

当我调用域时。com/xy 出现 404。我总是要输入域。com/xy.html.

是否要设置所有 .html 文件也可以在没有 .html 的情况下调用?

当前.htaccess

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

我已经尝试了以下方法,但不幸的是它不起作用。

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^([^\.]+)$ .html [NC,L]

我能做什么?谢谢!

你可以使用这个:

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
#remove .html
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^./]+)/?$ .html [L]
#rewrite non-existent requests to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]