Opened 2 years ago
Closed 2 years ago
#57177 closed defect (bug) (duplicate)
Trailing Dash (or Trailing Hyphen) Issue
Reported by: | Coodie | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | critical | Version: | 6.1.1 |
Component: | Permalinks | Keywords: | |
Focuses: | Cc: |
Description
All URLs with an added trailing dash or hyphen still function.
Example: domain.com/page is my URL, however domain.com/page- works and does not redirect when the actual URL of the page.
This also happens with trailing slash. Example:
domain.com/page/ is the URL, domain.com/page-/ also works.
The canonical URL in the page source correctly shows the URL without the dash/hyphen (-). But this doesn't prevent the page from showing up in search results, so we're getting data in our analytics showing traffic to both URLs. Here's a screenshot showing a list of URLs in our analytics account for one site. All of these URLs should not have the trailing dash.
I have tried adding this line to my htaccess
RewriteRule ^(.*)-$ $1 [QSA,R=301,L] # Redirect requests to hyphen-terminated URLs
And while that does redirect the URL so it doesn't have the trailing dash, it causes a redirect loop when trying to access wp-admin. So that's not an option.
I don't know if this is specific to WP 6+ versions or it was something that's been happening for a while, but it should be addressed.
Live example
Real URL:
https://webdevhandyman.com/services/custom-wordpress-theme
Working URLs with trailing dashes that should redirect back to the actual URL or should at the very least show as 404:
https://webdevhandyman.com/services/custom-wordpress-theme-
https://webdevhandyman.com/services/custom-wordpress-theme--
(and it doesn't matter how many dashes you add, they all work)
Hi there, welcome to WordPress Trac!
Thanks for the report, we're already tracking this issue in #14773.