mkdocs / mkdocs-redirects

Open source plugin for Mkdocs page redirects
MIT License
177 stars 26 forks source link

Redirect targets don't respect site_url or other non-root MkDocs uses #11

Closed LPGhatguy closed 4 years ago

LPGhatguy commented 4 years ago

My docs website lives at https://rojo.space/docs, a part of a larger website not managed by MkDocs.

I have a redirect setup like this:

  - redirects:
      redirect_maps:
        'latest/index.md': 'index.md'

I'm expecting this to redirect from https://rojo.space/docs/latest to https://rojo.space/docs, but it instead redirects to https://rojo.space.

I would expect mkdocs-redirects to use the site_url configuration value to know that my docs website is not at the root, and generate appropriate redirects. It is set to https://rojo.space/docs for this site.

prcr commented 4 years ago

Chiming in to let you know I have identified the same issue, meaning this bug report also affects me.

burkestar commented 4 years ago

Should be resolved in v1.0.1 released just now, thanks to the contribution from @prcr

luweizheng commented 4 years ago

@burkestar @prcr I have the same issue,and I am using 1.0.1.

plugins:
    - redirects:
        redirect_maps:
            'app/Jupyterlab-With-GPU.md': 'app/Jupyterlab.md'

I want http://mydomain/help/app/Jupyterlab-With-GPU/ redirects to http://mydomain/help/app/Jupyterlab/. But I got http://mydomain/app/Jupyterlab/.

Is there some other configurations I need to do?

ghost commented 4 years ago

Hi @luweizheng, just to check, do you have the site_url project settting defined (https://www.mkdocs.org/user-guide/configuration/#site_url)? The mkdocs-redirects plugin should now be using this setting to correctly determine the target URL of the redirect.

luweizheng commented 4 years ago

Hi @prcr I did not set site_url before and after I set it, It works! Thank you so much for your suggestions.

for others who have the same problem, you must set site_url correct, like this:

site_url: 'http://mydomain/help/'

plugins:
    - redirects:
        redirect_maps:
            'app/a.md': 'app/b.md'

Then http://mydomain/help/app/a/ will redirect to http://mydomain/help/app/b/.