简体   繁体   中英

Using htaccess for wordpress attachment URLs

We appear to have an issue with a bunch of old-style wordpress URLs, for example:

http://example.com/?attachment_id=11894

Which don't exist.

I'd like them to drop out of the index entirely, so I'd like to serve a 410 GONE status, ideally with .htaccess is there a RewriteRule or similar pattern I can use to get rid of them for once and all?

RewriteCond %{QUERY_STRING} (^|&)attachment_id= [NC]
RewriteRule / - [G]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM