zoukankan      html  css  js  c++  java
  • GHOST CMS

    Redirects

    In addition to creating routes, you can also create redirects for any time there are any changes in your URLs and you need to forward visitors

    Accessing the redirects file

    The redirects.json file is located in content/data/redirects.json and - like routes.yaml - can also be downloaded/uploaded in the settings in Ghost Admin.

    File structure

    This file always starts with a [ and ends with a ]. A new ghost publication will have an empty redirect file containing []. It can be edited in any source code editor.

    {
      "from": "/url/" ,
      "to":  "/url/",
      "permanent": true | false
    }
    • The from field defines the incoming URL or pattern (regex)
    • The to field defines where the incoming traffic should be redirected to, which can be a static URL, or a dynamic value using regex (example: "to": "/$1/").
    • The permanent field can be defined with true for a permanent 301 redirect, or false for a temporary 302 redirect.

    Multiple entries are separated by , and the last entry does not have the ,. Regular expressions can be used to implement redirect patterns.

    Implementation

    Upload your new redirects.json file in Ghost admin in the settings. This is the recommended method.

    To replace the JSON file on the server, ensure it exists in content/data/redirects.jsonand run ghost restart for your changes to take effect.

    When not to use redirects.json

    There are some instances where it is not recommended to use the redirects.json file:

    • Page rules for www or HTTP/HTTPS redirection should always be implemented with your DNS provider.
    • Ghost automatically forces trailing slashes, so you do not need to write any page rules to accommodate for duplicate content caused by this.
    • If you're trying to change the URL structure of your publication, the recommended way to do this is with dynamic routing and the routes.yaml file. (However, you may still need to redirect existing content using redirects.json).
  • 相关阅读:
    Django forms组件
    Django 分页器
    Django Ajax
    Django 多表操作2
    js12种应该注意的地方
    Web自动化测试python环境中安装 --selenium安装、火狐和火狐驱动版本、谷歌和谷歌驱动版本、测试
    python学习-文件操作
    关于redis搭建环境
    扩展知识
    javascript之Banner图片焦点轮播
  • 原文地址:https://www.cnblogs.com/QDuck/p/12081561.html
Copyright © 2011-2022 走看看