Our webpage was redesigned and moved to a web CMS platform. This means some of our blog posts shared via Twitter just link to a 404 page.

I am wondering if it is possible using .htaccess or something to redirect the HTTP_REFERER to the new blog post page URL.

I have tried the following, however, it wasn't working. The HTTP_REFERER domain should be t.co but I couldn't post that in this message.

# Twitter Redirect old links
RewriteCond %{HTTP_REFERER} ^https://t.co/StrIngOfLeTTeRs
RewriteRule ^ https://www.example.com/new-blog-permalink/

Not sure where I am going wrong so any advice would be welcome.

  • You can't redirect referrers. You redirect the site and the referrer comes along for the ride. – Stephen Ostermiller Jul 12 '17 at 9:03
  • "should be t.co but I couldn't post that in this message" - why not? The question is harder to read otherwise? Also, wondering why you are focusing on the HTTP Referer, rather than the URL that triggers the 404? Are you wanting to simply redirect all links from Twitter to a single blog post? (Which would likely be bad for SEO and result in a bad user experience anyway.) – MrWhite Jul 12 '17 at 10:07

Shouldn't you be redirecting the blogs themselves instead? You would need to do so anyway to help the search engines and referral links. That way the page that the t.co links points to will get picked up by the .htaccess file, and then redirect to the new blog permalink.

Redirect 301 /StrIngOfLeTTeRs /new-blog-permalink/

Not the answer you're looking for? Browse other questions tagged or ask your own question.