Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I have a website and it redirects users to their corresponding U.S. states page if they are in the U.S. region. For example, if I am in New York and I go to the website the page automatically redirected me to domainname.com/newyork. If I am from India, it opens the home page and asks me to select the state.

So for domainname.com, if I search for this website on Google, it shows domainname.com/california as a home page.

How can I rectify this? I want domainname.com as the home page for search engines.

share|improve this question
    
Are you using rel="alternate" hreflang="x" to serve the relevant visitor locations their geo-targeted page? If so, have you also listed the homepage at the end of these <head> tags so a search engine knows what to display in the event there is no alternate available? –  zigojacko Feb 11 at 10:06
    
I don't use hreflang. The site has only English content and it just redirect users to their region. –  Vasanthan.R.P Feb 11 at 10:38
    
You should still use hreflang for what you're doing, this is what it is designed for. Your custom implementation is probably also serving the california page for the IP location of the Googlebot that visits your website. I'd fetch your homepage as Googlebot and see what it returns. You'll have to change how you're handing this, ideally by implementing hreflang. –  zigojacko Feb 11 at 10:43
1  
@Vasanthan.R.P Sounds like you're using IP Delivery to redirect by state and country, so depending on where the crawler's IP address is located (e.g., California), they'll be directed to the corresponding page. You can research what IP addresses crawlers use, but that can be somewhat imprecise and would need updating. If you redirect based on the user agent instead though, that might be considered cloaking. –  dan Feb 11 at 19:33
add comment

1 Answer

up vote 1 down vote accepted

Your question doesn't state any details about your hosting environment, however supposing you were on a Linux/Apache/PHP web server configuration, you might use a RewriteRule in a .htaccess file in the website public root folder such as the following to make sure that search engines are dealt your homepage before any clever location-based routing is applied:

RewriteCond %{HTTP_USER_AGENT} AltaVista [OR]
RewriteCond %{HTTP_USER_AGENT} Bingbot [OR]
RewriteCond %{HTTP_USER_AGENT} Googlebot [OR]
RewriteCond %{HTTP_USER_AGENT} msnbot [OR]
RewriteCond %{HTTP_USER_AGENT} Slurp
RewriteRule ^.*$ http://www.example.com/index.php?state=none [L,QSA]

Obviously you can add as many search engines to the list as you like, check the Search Engine Dictionary for a list of spider names. The [L] switch makes this the last rule to apply if any of the preceeding conditions were met. The [QSA] switch preserves any query string that might exist before this rule is applied. I've made up a script index.php and a parameter value pair state=none as an example of how you could identify this scenario from your pages.

If you're using a different hosting environment or server-side programming language then I'm sure the same principles could apply with a slightly different implementation.

share|improve this answer
    
I didn't use this exactly but get the HTTP_USER_AGENT through php and sop the redirection if it is from bots. This answer really help to sort this out. Thanks –  Vasanthan.R.P Feb 19 at 13:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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