【问题标题】:Problems removing html extensions from https:// 123-reg hosting htaccess file从 https:// 123-reg 托管 htaccess 文件中删除 html 扩展的问题
【发布时间】:2018-02-02 16:07:54
【问题描述】:

这是我第一次使用 123-reg 进行网站托管(我通常使用其他主机)。该网站有一个 SSL 证书,并且 htaccess 文件重定向到 https:// 但是......它没有从页面中删除 html 扩展名(当它是 http:// 时它确实删除了它们)

123-reg 说这是我在做或不做的事情,但下面的 htaccess 代码在我的其他主机上工作得很好,只是不是 123-reg。

我正在使用的 htaccess 代码(也指向 https:// )

RewriteEngine On
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

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

这是网站网址:https://buyrich.co.uk/

【问题讨论】:

  • 当你没有去一个 html 文件时你会得到什么错误。最后添加html扩展名?
  • 如果我手动删除 html 扩展名,我不会收到错误代码,但只要我点击另一个页面,html 扩展名就会重新出现
  • 您使用的规则不会删除 .html 扩展名。它只是使您即使没有 .html 也可以访问您的 html 文件。如果您想从您的网址中完全删除 .html 扩展名,请参阅以下帖子 stackoverflow.com/questions/5730092/how-to-remove-html-from-url
  • 我查看了该帖子并将以下代码添加到 htaccess 文件中,但这也不起作用?我需要在下面将 http 更改为 https 吗? RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /html/(.*).html\ HTTP/ RewriteRule .* localhost/html/%1 [R=301,L] RewriteCond %{THE_REQUEST} ^[A-Z ]{3,9}\ /html/(.*)\ HTTP/ RewriteRule .* %1.html [L]

标签: .htaccess ssl


【解决方案1】:

我想我已经用该帖子中的代码修复了它,谢谢:

RewriteEngine on


RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]

重写条件 重写规则 ^ /%1 [NC,L,R]

 RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-29
    • 1970-01-01
    • 2016-12-28
    • 1970-01-01
    • 1970-01-01
    • 2015-04-22
    • 2012-05-27
    相关资源
    最近更新 更多