How should I handle a mobile website redirect with Twitter cards?


Dear Birdie,

We have and, two separate websites. The first one handles mobile clients and redirect browsers.

We have users sharing the m. website, like so: We want that to automatically become the non-mobile website so that the card appears.

Is it enough to detect the Twitter BOT (and if so what do we look in for the user agent)? What’s the best way to handle this?


Hi Daniel,

One option is to have the Card appear on both properties.

Otherwise, a redirect should tell our Twitterbot to cache the Card for the final destination accordingly.



Ryan, I cannot find any documentation on what Twitterbot user-agent is? Anything?


Nm, found it here:, Twitterbot.


The validator tool doesn’t test these.

Validator broken, but redirect is there:

$ curl -v -H “User-Agent:Twitterbot”

  • About to connect() to port 80 (#0)
  • Trying… connected
  • Connected to ( port 80 (#0)

GET /post/editorial-the-artsy-questionnaire-raul-de-molina-photojournalist-turned-collector HTTP/1.1
Accept: /

< HTTP/1.1 302 Moved Temporarily
< Content-Type: text/plain
< Date: Fri, 27 Sep 2013 22:57:09 GMT
< Location:
< Vary: Accept
< X-Powered-By: Express
< Content-Length: 137
< Connection: keep-alive

  • Connection #0 to host left intact
  • Closing connection #0


And just to be clear, the tweets with don’t show cards, the redirect has been in place for a week.


Thanks for the detail. This is super helpful.

The only thing I can think of is changing the 302 to a 301. I looked at doing a curl against a twitter URL and saw this:

  • Connected to ( port 80 (#0)

Accept: /

< HTTP/1.1 301 Moved Permanently
< cache-control: private,max-age=300
< date: Tue, 01 Oct 2013 16:35:06 GMT
< expires: Thu, 01-Jan-1970 00:00:00 GMT
< location:
< server: tfe
< set-cookie: muc=1;;Expires=Sun, 13-Sep-2015 16:35:06 GMT
< Content-Length: 0


Changed it to a 301, no change.

Can someone with their hands in the code please take a look? I’ve been tracking this for almost a month.


Sorry for the delay. Been very swamped.

Out of curiosity, could you try to do a test to see what and use as redirects (since they both work), and see how that might differ from what you’re doing?

Please post the response here.



Ok, figured this out. The user-agent that Twitter sends is Twitterbot/1.0, not just Twitterbot. I should have checked the logs. We just needed to match that.

This took way too long to resolve for something that silly. If I may suggest a few things for the Twitter team:

  • Document that twitter cards support redirects. Figure out whether a permanent vs. temporary redirect is actually required so that we’re not left guessing.
  • Document the twitterbot UA fully, maybe in a single FAQ, whenever something changes (version, etc.), document that too.



Apologies, and hope looking at helped.

I’ve updated a couple places of documentation to specifically call out the version as well:

Know it’s too late for you, but hope it helps others.

Let me know if there are other places this would be useful.


Add something about the fact that Twitter follows redirects. Ideally figure out whether 301 or 302 or both work. Also how far does Twitter follow redirects? Till forever unless there’s a loop?


@rchoi, another problem is SSL, the validator says is OK, but doesn’t show a card.

Two things that are different from the mobile site problem:

  • This is a 301 non-permanent redirect.
  • This site has a robots.txt that disallows robots. But it’s a redirect so I assume it shouldn’t matter at all.

Given that the validator works, could you please provide some definite answers instead of me poking in the dark?


@rchoi, update, this just started working, I suppose something was cached (or someone fixed something), even though it’s weird as I was trying new URLs