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

Site title block links to wrong home url causing a useless redirect #65670

Open
2 tasks done
Chouby opened this issue Sep 26, 2024 · 4 comments · May be fixed by #65672
Open
2 tasks done

Site title block links to wrong home url causing a useless redirect #65670

Chouby opened this issue Sep 26, 2024 · 4 comments · May be fixed by #65672
Assignees
Labels
[Block] Site Title Affects the Site Title Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@Chouby
Copy link
Contributor

Chouby commented Sep 26, 2024

Description

When WordPress is installed in a subfolder, the home url is let say https://mysite.com/wordpress/ with a trailing slash. However the site title block links to https://mysite.com/wordpress without trailing slash which is then redirected to the canonical url https://mysite.com/wordpress/.

The same kind of issue occurs for multisite where sites are installed in folders.

Step-by-step reproduction instructions

  1. Install WordPress in a subfolder with a default theme.
  2. Create a page and insert the site title block
  3. View the page on frontend
  4. Open the browser tools to observe that there will be a redirect.
  5. Check the link proposed by the site title block is https://mysite.com/wordpress
  6. Click on the link and observe that there is 301 redirect from https://mysite.com/wordpress to https://mysite.com/wordpress/

Screenshots, screen recording, code snippet

No response

Environment info

WP 6.6 + Twenty Twenty Four

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes
@Chouby Chouby added the [Type] Bug An existing feature does not function as intended label Sep 26, 2024
@Mamaduka Mamaduka added the [Block] Site Title Affects the Site Title Block label Sep 26, 2024
@Mamaduka
Copy link
Member

Hi, @Chouby

The Site Title block uses the home_url function as the link. This could be an issue with the WP subfolder installation itself, or there's a filter that modifies the home_url behavior.

What result do you get if you run echo home_url()?

@Mamaduka Mamaduka added the Needs Testing Needs further testing to be confirmed. label Sep 26, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Sep 26, 2024
@Chouby
Copy link
Contributor Author

Chouby commented Sep 26, 2024

Hi @Mamaduka,
You went too fast for me ;). I was preparing the PR to add the slash in home_url().
When I run echo home_url(), I get https://mysite.com/wordpress.
When I run echo home_url( '/' ), I get https://mysite.com/wordpress/.

@Mamaduka
Copy link
Member

Thank you, @Chouby!

I checked similar usages in WP core, like "Visit Site" in the admin bar, and it's using a trailing slash, which seems like the correct solution.

Here's the old core ticket for a similar issue: https://core.trac.wordpress.org/ticket/19314.

Also, I think we should update the Home Link block. Would you mind including it in your PR?

cc @SergeyBiryukov

@Mamaduka Mamaduka removed the [Status] In Progress Tracking issues with work in progress label Sep 26, 2024
@Chouby
Copy link
Contributor Author

Chouby commented Sep 26, 2024

Done for the home Link block too.

@Mamaduka Mamaduka added [Status] In Progress Tracking issues with work in progress and removed Needs Testing Needs further testing to be confirmed. labels Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Site Title Affects the Site Title Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants