【发布时间】:2020-09-28 05:37:32
【问题描述】:
我想在 URL 中隐藏 .html 扩展名,我通过编辑 .htaccess 文件来做到这一点。如果我单击任何页面,则它会在没有 .html 扩展名的情况下打开,但是当我手动输入带有 .html 扩展名的 url 时,它也会打开该页面,并且 .html 扩展名会出现在 URL 中。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.html [L]
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php71” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php71 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
我的要求是即使我在 url 中输入 .html 也不允许打开页面。或者它应该在用户输入带有 .html 扩展名的 URL 时自动重定向。
不知道上面的代码是否正确。请帮我修复它。 网址:https://drkrinitamotwani.com/
【问题讨论】:
标签: html .htaccess url redirect