【问题标题】:How to change example.com/blog.html to example.com/blog如何将 example.com/blog.html 更改为 example.com/blog
【发布时间】:2019-05-18 05:59:03
【问题描述】:

www.tinynerdgames.com/blog.html


我希望此页面的 URL 不以 /blog.html 结尾,而是以 /blog 结尾。所以希望的最终结果是:www.tinynerdgames.com/blog

我该怎么办?

非常感谢任何答案,谢谢。

【问题讨论】:

  • 如何确定哪些 URL 提供哪些资源取决于您的 HTTP 服务器和/或服务器端代码,您在问题中都没有提及。

标签: html web url


【解决方案1】:

您可以使用 .htaccess 文件截断您的文件 URL。

导航到 cPanel 中的文件管理器并找到 .htaccess 文件。注意:您必须启用隐藏文件才能查看此文件。

  • 点击右上角的设置
  • 选择显示隐藏文件(点文件)
  • 保存新设置

在 htaccess 文件中,粘贴这段代码;

#remove html file extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

现在将您的链接从https://tinynerdgames.com/blog.html 更改为https://tinynerdgames.com/blog,这应该可以完美运行。

【讨论】:

    【解决方案2】:

    使用 FTP,您将登录到您的网站,创建一个名为 blog 的目录,将 blog.html 文件移动到新目录中,并将 blog.html 重命名为 index.html

    【讨论】:

    • 试过了,但没用。它说 example.com/blog/index.html
    • 尝试在您的 URL 中的博客后使用 /www.tinynergames.com/blog/。顺便说一句,喜欢你网站的名字!
    猜你喜欢
    • 1970-01-01
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    • 2012-01-22
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2022-01-02
    相关资源
    最近更新 更多