idarek
1
Hello All,
Just finish migrating my WordPress site to Hugo and deployed my site via Netlify.
Currently I am trying to sort redirects and reading documentation about _redirects file manager to achieve almost all.
Almost…
When moved from wordpress, I (intentionally) resigned from AMP (for now) and would like to redirect old AMP links to non-AMP.
https://mysite.url/mypost/amp/
to
https://mysite.url/mypost/
Without specifying it for each individually
Easy is to do with :splat for everything whats after url, but how to do that whats before?
just need to remove /amp/ from URL end if requested in such way
@idarek Welcome to the Netlify community.
Have you tried something like:
[[redirects]]
from = "https://mysite.url/mypost/amp/*"
to = "https://mysite.url/mypost/:splat"
status = 301
force = false
AKA
https://mysite.url/mypost/amp/* https://mysite.url/mypost/:splat 301
idarek
3
Thank, but part of /mypost/ is dynamic hence if I want to do this that way, that means I will need to do for 190+ posts.
idarek
4
Looking more like an equivalent of .htaccess rule
RewriteEngine On
RewriteRule ^(.*)/amp/?$ /$1/ [L,R=301]
idea
https://mysite.url/*/amp https://mysite.url/$1
idarek
5
Before I will brake something, do you think this will work?
/*/amp/ /:splat 301
wonder if asterisk will catch only whats between / and /amp/ ?
Scott
6
It won’t be a splat you’re after, in that situation, it’ll be a placeholder:
https://docs.netlify.com/routing/redirects/redirect-options/#placeholders
So, something like /:context/amp /:context 301
should do it!
1 Like
idarek
7
Thanks for that, didn’t know about :context
as is not really described in linked page that you provided. Think worth to update with it.
Will have a try later today and let you know.