当前位置: 首页 > 软件库 > Web应用开发 > >

jekyll-redirect-from

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发
软件类型 开源软件
地区 不详
投 递 者 索梓
操作系统 未知
开源组织
适用人群 未知
 软件概览

JekyllRedirectFrom

Give your Jekyll posts and pages multiple URLs.

When importing your posts and pages from, say, Tumblr, it's annoying andimpractical to create new pages in the proper subdirectories so they, e.g./post/123456789/my-slug-that-is-often-incompl, redirect to the new post URL.

Instead of dealing with maintaining those pages for redirection, letjekyll-redirect-from handle it for you.

Build Status

How it Works

Redirects are performed by serving an HTML file with an HTTP-REFRESH metatag which points to your destination. No .htaccess file, nginx conf, xmlfile, or anything else will be generated. It simply creates HTML files.

Installation

Add this line to your application's Gemfile:

gem 'jekyll-redirect-from'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jekyll-redirect-from

Once it's installed into your environment, add it to your _config.yml:

plugins:
  - jekyll-redirect-from

�� If you are using a Jekyll version less than 3.5.0, use the gems key instead of plugins.

If you're using Jekyll in safe mode to mimic GitHub Pages, make sure toadd jekyll-redirect-from to your whitelist:

whitelist:
  - jekyll-redirect-from

Then run jekyll <cmd> --safe like normal.

Usage

The objective of this gem is to allow an author to specify multiple URLs for apage, such that the alternative URLs redirect to the new Jekyll URL.

To use it, simply add the array to the YAML front-matter of your page or post:

title: My amazing post
redirect_from:
  - /post/123456789/
  - /post/123456789/my-amazing-post/

Redirects including a trailing slash will generate a corresponding subdirectory containing an index.html, while redirects without a trailing slash will generate a corresponding filename without an extension, and without a subdirectory.

For example...

redirect_from:
  - /post/123456789/my-amazing-post

...will generate the following page in the destination:

/post/123456789/my-amazing-post

While...

redirect_from:
  - /post/123456789/my-amazing-post/

...will generate the following page in the destination:

/post/123456789/my-amazing-post/index.html

These pages will contain an HTTP-REFRESH meta tag which redirect to your URL.

You can also specify just one url like this:

title: My other awesome post
redirect_from: /post/123456798/

Prefix

If site.url is set, its value, together with site.baseurl, is used as a prefix for the redirect url automatically. This is useful for scenarios where a site isn't available from the domain root, so the redirects point to the correct path. If site.url is not set, only site.baseurl is used, if set.

Note: If you are hosting your Jekyll site on GitHub Pages, and site.url is not set, the prefix is set to the pages domain name i.e. http://example.github.io/project or a custom CNAME.

Redirect To

Sometimes, you may want to redirect a site page to a totally different website. This plugin also supports that with the redirect_to key:

title: My amazing post
redirect_to: http://www.github.com

Note: Using redirect_to or redirect_from with collections will only work with files which are output to HTML, such as .md, .textile, .html etc.

Customizing the redirect template

If you want to customize the redirect template, you can. Simply create a layout in your site's _layouts directory called redirect.html.

Your layout will get the following variables:

  • page.redirect.from - the relative path to the redirect page
  • page.redirect.to - the absolute URL (where available) to the target page

Configuration

You can configure this plugin in _config.yml by adding to the redirect_from key.

Disabling redirects.json

By default, a file called redirects.json, which can be used for automated testing or to implement server-side redirects, will be included in the output. To exclude it from the output, set the json key to false:

redirect_from:
  json: false

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
 相关资料
  • return Redirect::to('foo/bar'); return Redirect::to('foo/bar')->with('key', 'value'); return Redirect::to('foo/bar')->withInput(Input::get()); return Redirect::to('foo/bar')->withInput(Input::except('

  • 设置302调整,配置方式: pattern redirect://jumpUrl jumpUrl为请求要302跳转的目标url,pattern参见匹配模式,更多模式请参考配置方式。 例子: www.ifeng.com redirect://http://www.aliexpress.com/ 不需要追加参数 www.test.com/index.html redirect://`https:/

  • 什么是页面重定向? 您可能遇到过这样的情况:您单击了一个URL以到达页面X,但在内部您被定向到另一个页面Y.它是由于page redirection而发生的。 这个概念与JavaScript页面刷新不同。 您可能有多种原因要从原始页面重定向用户。 我们列出了一些原因 - 您不喜欢您的域名,而您正在转向新域名。 在这种情况下,您可能希望将所有访问者定向到新网站。 在这里,您可以维护旧域,但只需将页面

  • App-redirect(Redirect)是一个 SpringBoot 应用程序,基于 urlrewrite.xml 中的配置规则能够解决重定向问题。它使用 UrlRewriteFilter 来进行重定向。 用途: git clone git@github.com:pivotal/app-redirect.gitcd app-redirect make changes in src/main/r

  • Initial Redirect (IR) 是一个 Squid 的插件,用来检测如果是新用户,就自动将请求重定向到指定的页面。可用在一些公共的无线AP,重定向页面可以是支持策略、地址等的页面。

  • 一些网页在重定向到最终页面之前使用中间页面。Skip Redirect 就是一个尝试从中间 url 中提取最终 url 的插件,如果成功提取则会立即跳转至最终页面。 默认情况下,除了与 no-skip-urls-list 相匹配的 URL 外,所有的 URL 都被检查为嵌入式 URL,并跳过重定向。根据访问的页面,这可能会导致登录功能障碍等问题。可以对 no-skip-urls-list 进行编辑