最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

htaccess - how to redirect 404 to attachment.php?

programmeradmin3浏览0评论

I have a problem, I have many url attachments with / amp, example:

siteweb/article-2019/image2/amp
siteweb/article-2019/image3/amp
siteweb/article-2019/image4/amp

all these give me 404 error But the original url and where the images are are like this

siteweb/article-2019/image2/
siteweb/article-2019/image3/
siteweb/article-2019/image4/

Any way to do it with htacces?

I have a problem, I have many url attachments with / amp, example:

siteweb/article-2019/image2/amp
siteweb/article-2019/image3/amp
siteweb/article-2019/image4/amp

all these give me 404 error But the original url and where the images are are like this

siteweb/article-2019/image2/
siteweb/article-2019/image3/
siteweb/article-2019/image4/

Any way to do it with htacces?

Share Improve this question asked Jan 20, 2020 at 19:52 Plantas y remedios CaserosPlantas y remedios Caseros 33 bronze badges 1
  • 1 attachment.php doesn't determine what gets shown, what gets shown determines the template, by the time WP tries to figure out which template to show, it's already fetched the posts. I'd suggest reporting this bug to the vendor that implements your Amp support ( and asking them to support attachment pages in Amp ) – Tom J Nowell Commented Jan 20, 2020 at 20:29
Add a comment  | 

1 Answer 1

Reset to default 0

Try something like the following at the top of your .htaccess file, before the WordPress front-controller:

RewriteRule (.+/)amp$ /$1 [R,L]

This redirects a request for /<something>/amp to /<something/ - removing the "amp" suffix.

Note that this is a 302 (temporary) redirect.

发布评论

评论列表(0)

  1. 暂无评论