metabolism / wordpress-bundle

Use Wordpress and Symfony together using a Symfony bundle
MIT License
62 stars 17 forks source link

Use Symfony trailing slash policy in Page routes #30

Closed adlpz closed 2 years ago

adlpz commented 2 years ago

When a route is defined without trailing slash Symfony redirects with 301 to it when accessing the same URL with trailing slash. However in the current Page route definition the pagename parameter would accept anything including trailing slashes and Wordpress would find it and return the correct post, causing 200 responses both in the /{slug} page as well as the /{slug}/, which hurts SEO.

Given that and knowing that Wordpress won't allow slashes in slugs, we change the pagename regex to reject trailing slashes and therefore serve 200 responses on naked slugs and 301 on trailing slashes, as expected.