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

redirect some case-sensitive URLs #5

Open
xhdix opened this issue Oct 18, 2021 · 2 comments
Open

redirect some case-sensitive URLs #5

xhdix opened this issue Oct 18, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@xhdix
Copy link
Contributor

xhdix commented Oct 18, 2021

@xhdix xhdix added the bug Something isn't working label Oct 18, 2021
@0vj
Copy link

0vj commented Sep 17, 2022

Hi. I think there is no right way to solve this problem. "GitHub Pages" only supports static sites. To properly implement this issue, the website needs to be dynamic, In general, I found an interesting idea by searching(link).
here when the user receives a 404 page a JavaScript code:

<script>
    window.onload = () => {
        currentURL = window.location.href;
        lowerCaseURL = currentURL.toLowerCase();
        if (currentURL != lowerCaseURL) {
            location.replace(lowerCaseURL);
        }
    };
</script>

redirects the page to the same address but in lower case. Since I think you don't intend to change the current addresses and make them lower case, we can add a script to the site generator workflow to generate something similar to a dictionary where the keys are the site addresses in lower case and the values be the main addresses.
for example:

redirects: = {
  "fa/docs/measure-internet-censorship/network": "fa/docs/measure-internet-censorship/Network",
  "fa/docs/measure-internet-censorship/ooni": "fa/docs/measure-internet-censorship/OONI",
  "fa/docs/measure-internet-censorship/dns": "fa/docs/measure-internet-censorship/DNS",
}

Then changes must be made in the JavaScript code so that the address entered by the user in lowercase letters is used as the key and the user is redirected to the address of the key value.

I'm not a javascript developer but I think I can implement this. If you agree with this method, let me know.

@xhdix
Copy link
Contributor Author

xhdix commented Sep 18, 2022

Thank you @mr-tafreshi, but I think using _redirects is a better way to do it.
e.g.: https://github.com/ooni/ooni.org/blob/master/_redirects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants