Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirects don't work locally #17

Closed
wilhelmer opened this issue Sep 23, 2020 · 0 comments · Fixed by #19
Closed

Redirects don't work locally #17

wilhelmer opened this issue Sep 23, 2020 · 0 comments · Fixed by #19

Comments

@wilhelmer
Copy link

wilhelmer commented Sep 23, 2020

When the HTML output files are accessed locally (file:// protocol), the redirects don't work.

This is because of the leading slash in the redirect target.

Tested in Firefox and Chrome.

mkdocs.yml

use_directory_urls: false
plugins:
    - redirects:
        redirect_maps:
            'old.md': 'new.md'

old.html

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Redirecting...</title>
    <link rel="canonical" href="/new.html">
    <meta name="robots" content="noindex">
    <script>var anchor = window.location.hash.substr(1); location.href = "/new.html" + (anchor ? "#" + anchor : "")</script>
    <meta http-equiv="refresh" content="0; url=/new.html">
</head>

<body>
    Redirecting...
</body>

</html>

Solution

If I manually replace /new.html by new.html, everything works fine, both locally and on the web, and both in Chrome and Firefox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant