-
Notifications
You must be signed in to change notification settings - Fork 642
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
A site's root URL always has a trailing slash, regardless of addTrailingSlashesToUrls
#5675
Comments
@benface This isn't Craft CMS's related solution but you could solve it with web server. I use NGINX and all trailing slashes at the end of URI that web server match rewrites and friendly 301 redirects it to URI with no trailing slash.
Your actual result: As this minor bug is coming from Craft CMS than it'd solved. |
@dominikkrulak Thank you. Yes, I know and already do this. The issue is that following a link to the home page causes a 301 redirect (so two requests instead of one), since the original link from Craft contains a trailing slash, and the web server redirects to the no-trailing-slash URL. |
Unfortunately this is going to have to wait until 4.0, because it would end up breaking a lot of templates that currently do things like: <link rel="stylesheet" type="text/css" href="{{ siteUrl }}assets/style.css"> That assumes that |
Ah yeah, I see. No problem at all. |
Also, while this is definitely a bit awkward for site URLs that include a URI segment (e.g. |
If use SEOmatic and you're looking for a temporary work-around for this issue, this is how I solved it for our sites temporarily until the fix comes out: {% set currentUrl = currentSite.handle == 'english' ? entry.url : entry.url|trim('/', 'right') %}
{% do seomatic.meta.canonicalUrl(currentUrl) %} For our sites, this gives us: It's definitely not hack-free, but it works nicely and it's only one extra line of code in my template. |
Very old issue, but it's still there. Any update on this? |
Sorry, looks like this fell through the cracks. Just added it to our v6 list. In the meantime, the previous workaround will still do the trick. |
Noticed this issue on my end as well - what is the temporary solution for alternate and sitemaps urls (seomatic) etc? Affects single home page entry url with subdirectory like |
…prefix strip trailing slashes as appropriate ([#717](#717)) ([#5675](craftcms/cms#5675))
…prefix strip trailing slashes as appropriate ([#717](#717)) ([#5675](craftcms/cms#5675))
…prefix strip trailing slashes as appropriate ([#717](#717)) ([#5675](craftcms/cms#5675))
While I think this is largely as non-issue, and will not affect SEO in any measurable way, I've implemented it in SEOmatic. Craft CMS 3: You can try it now by setting your semver in your "nystudio107/craft-seomatic": "dev-develop as 3.5.10”, Then do a ….. Craft CMS 4: You can try it now by setting your semver in your "nystudio107/craft-seomatic": "dev-develop-v4 as 4.1.9”, Then do a ….. Craft CMS 5: You can try it now by setting your semver in your "nystudio107/craft-seomatic": "dev-develop-v5 as 5.1.9”, Then do a |
Steps to reproduce
addTrailingSlashesToUrls
tofalse
(or just don't set it, as it's the default){{ siteUrl() }}
https://example.com/en
Expected result:
https://example.com/en
Actual result:
https://example.com/en/
Additional info
The text was updated successfully, but these errors were encountered: