turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

Http status 301 Moved Permanently/302 Found vs 200 Ok #254

Closed fseixas closed 8 years ago

fseixas commented 8 years ago

Hi,

I´m having some issues regarding http status codes returned by i18n.

I have a site that has two languages. The default language en and also a additional pt-br.

When accessing the site using the default language, the site always return a "302 found" http status code (or "Moved 301 Permanently" depending on the i18n.LocalizedApplication.Current.PermanentRedirects config) while accessing the site using the pt-br, the site always return a "200 ok" status code. (see attachment)

That does not seams to be a problem as the site should work perfect the bought ways but the is a issue with web crawling done by sites like Facebook and Slack to get the open graph tags from the html.

Facebook for example does not accept the 301 or 302 for scrapping open graph data. Must be a 200 code.

If you use the Open Graph Object Debugger tool from Facebook (https://developers.facebook.com/tools/debug/og/object/) and enter the URLs http://www.leadgrid.io/en/prelaunch and http://www.leadgrid.io/pt-br/prelaunch (use the "Fetch new scrape information" button) you will see that Facebook can get the open graph data from pt-br but not from en. The same occurs in Slack web scrapping agent (see attachment).

This data is important for when someone share the url on Facebook to have all the descriptions and preview images set correctly.

I believe that the default language should return a 200 ok status code just as the additional languages.

Thanks,

2016-01-31 01_37_07-jack sistemas - slack 2016-01-31 01_23_47-view http request and response header 2016-01-31 01_22_57-view http request and response header

turquoiseowl commented 8 years ago

It looks like something is not quite right here. You should not get a redirect like that from the default language. I've just tested with a site (using i18n scheme 1 and default language "en"). A request for domain.com/en gets a 200, so does a request for domain.com/en/features.

If you can build against the i18n source and debug the EarlyUrlLocalizer.ProcessIncoming method you should be able to discover what's going on.

fseixas commented 8 years ago

It was a bug in our IP geo location implementation. When accessing the default language our app entered in a eternal loop of 302 redirects when accessed by web crawlers.

Thanks for helping.