Skip to content

Conversation

@amieiro
Copy link
Member

@amieiro amieiro commented Sep 25, 2023

Problem

When you access the https://glotpress.test/glotpress URI (without a slash at the end of the URI), you get a 404. Instead, if you add the slash at the end of the URI https://glotpress.test/glotpress/, you are redirected to https://glotpress.test/glotpress/projects/

Keep in mind, I am using https://glotpress.test/ as my main WordPress address. Please, change all the URI used in this description to the main URI used in your local installation.

Fixes #896.

Solution

This PR adds a slash at the end of the requested URI if it doesn't have it.

Testing Instructions

Test both URI in your local installation (with and without the final slash) before and after applying this PR:

  1. https://glotpress.test/glotpress
  2. https://glotpress.test/glotpress/

Before applying the PR, you will get a 404 with the first URI. After applying the PR, you will be redirected to the GlotPress main page.

@amieiro amieiro requested review from akirk and trymebytes September 25, 2023 11:25
trymebytes
trymebytes previously approved these changes Sep 25, 2023
@trymebytes
Copy link
Contributor

Tested and works for me.

Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am skeptic of this approach. For routing there is a function request_uri(). I think we should be working with that instead of modifying a PHP superglobal.

@amieiro amieiro requested a review from akirk September 25, 2023 15:32
Copy link
Member

@akirk akirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

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 this pull request may close these issues.

Allow access without trailing slash for site-url/glotpress

3 participants