[wp-trac] [WordPress Trac] #57177: Trailing Dash (or Trailing Hyphen) Issue

WordPress Trac noreply at wordpress.org
Tue Nov 22 18:48:56 UTC 2022


#57177: Trailing Dash (or Trailing Hyphen) Issue
--------------------------+-----------------------------
 Reporter:  Coodie        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Permalinks    |    Version:  6.1.1
 Severity:  critical      |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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.

 [[Image(https://www.kingsiegel.com/wp-content/uploads/2022/11/trailing-
 dash.png)]]

 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)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57177>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list