Skip to content

Add a slash at the end of a requested URI#1701

Merged
trymebytes merged 5 commits into
GlotPress:developfrom
amieiro:add-slash-end-request-uri
Sep 25, 2023
Merged

Add a slash at the end of a requested URI#1701
trymebytes merged 5 commits into
GlotPress:developfrom
amieiro:add-slash-end-request-uri

Conversation

@amieiro

@amieiro amieiro commented Sep 25, 2023

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor

Tested and works for me.

@akirk akirk left a comment

Copy link
Copy Markdown
Member

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.

Comment thread gp-includes/router.php Outdated
Comment thread gp-includes/router.php Outdated
@amieiro amieiro requested a review from akirk September 25, 2023 15:32

@akirk akirk left a comment

Copy link
Copy Markdown
Member

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