Automattic / Automattic/jetpack
Relative links broken in subscription emails if WP site is in subdirectory
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
#### Steps to reproduce the issue
1. Set WordPress home directory to https://www.mysite.com/blog/ (So all paths within WP are relative to /blog)
2. Subscribe to blog with Jetpack plugin
3. Create a new blog post with relative links like /my-page.html
#### What I expected
Email sent out to subscribers should have https://mysite.com/my-page.html as the link URL. This is how browsers interpret the link and is the W3C standard.
#### What happened instead
Email sent out to subscribers has https://mysite.com/blog/my-page.html as the link URL (including subdirectory /blog). This is breaking links in our emails, forcing us to create redirects for every such relative link we create.
This was working properly in previous versions of the plugin, at least as recently as v8.6.1. We are now on v9.2 and are experiencing this issue.
**Note:** Making the links absolute is not a viable solution for us as we are hosting the same blog on several different domains and want the relative links to work accordingly; i.e., if the post is accessed from https://www.mysite.ca/blog, the /my-page.html link will point to https://www.mysite.ca/my-page.html
Contributor guide
Research direction
No file or test is named in the issue. Start by reproducing the subscription email with a WordPress site in a subdirectory and a root-relative link, then trace how Jetpack rewrites links in outgoing emails. Done means links such as /my-page.html resolve to the site's domain root without the WordPress subdirectory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100