301 Redirect with Multiple Conditions

5 replies
  • SEO
  • |
Hi Friends

I'm working for my client site and i done 301 redirect from .com to .in and it's working
but when i put the url without www it's not working so i need satisfy two conditions, how should i do.
#301 #conditions #multiple #redirect
  • Profile picture of the author esdavis
    I'm not sure I 100% know what you are asking, but here's what I think you're asking.

    You have a domain named mydomain[dot]com. You want it to go to mydomain[dot]in

    You set up a redirect that takes the non-www version from .com to .in
    Are you using htaccess or some other thing like a php redirect?

    If htaccess, which works best for this for me, then you actually have to do a couple of rewrite conditions.

    Since each version of a domain www[dot]mydomain[dot]com and mydomain[dot]com are seen by Google and others as TWO DIFFERENT urls, a case coming in for www. is a different page to handle than one for (non-www) mydomain[dot]com.

    Assuming you want to use the non-www version in "real life use" you want to redirect all three of the others. The cleanest is to clean up the .com and then the .in

    So I'd first set up a rewrite condition from the www[dot]mydomain[dot]com to mydomain[dot]com with a 301. Do the rewrite rule to do it.

    Now all www[dot]mydomain[dot]com goes to mydomain[dot]com

    Next, redirect mydomain[dot]com to mydomain[dot]in (condition and rule)

    Now everything .com heads to mydomain[dot]in

    Lastly, catch anything incoming to the www[dot]mydomain[dot]in by doing one more condition rewrite from www[dot]mydomain[dot]in to mydomain[dot]in

    That should cover it.

    I don't do enough htaccess to know if you can do all conditions and then one rule to redirect, or not. I suspect the safest way would be to do condition, rule, condition, rule.

    And most importantly, do one step. Test the redirecting and redirected domains. Next one, test again, last one test again. All done, test them all.

    That way you catch one if it is broken before you monkey with the others.

    Now, if I had the question wrong altogether, I apologize. Some additional info would help to try to answer better.

    Oh, and other server-side folks here can probably give you better htaccess instructions than I could, but basically that's the way you do a single 301 domain redirect so I'm thinking it should work for more if you go step by step.

    Oh, and Hey Everyone, if I'm giving bad instructions, PLEASE shout out! I don't want to screw goodluckdomain up. Or teach myself bad habits.
    Signature
    Always Interested in Hearing About Cool SEO Tools and Useful WP Plugins via threads or PMs.

    Interested in Social Media Tools and Content for The Local Marketing Expert clients.
    {{ DiscussionBoard.errors[4173299].message }}
  • Profile picture of the author stephencammeron
    If that's the case, you also have to redirect the URL without www so that it will also work as well.
    Signature

    "People who rely on just a couple of concepts, only shows how clueless they are."

    {{ DiscussionBoard.errors[4173788].message }}
  • Profile picture of the author esdavis
    That's what I'm saying. You've got 3 to redirect all eventually to the 4th one. The cleanest way is a chain, so if you ever undid the part heading to mydomain[dot]in, your www to non-www mydomain[dot]com would still be in place.

    Anyway so:
    1. www. for .com goes to non-www for .com (stop here is standard .com redirection)
    2. non-www for .com goes to non-www for .in
    Now both .com domains end up at non-www .in
    3. www for .in goes to non-www for .in
    Now it also hits non-www .in

    You don't to redirect the traffic coming into mydomain[dot]in because that's where you want all links with those 4 incoming URLs to end up. 3 are redirected and the final one stays open and clear for traffic.

    I hope I haven't confused anyone and this update made things a little clearly.

    And really, if it makes you nervous or scares you, I'm sure you can get somebody on Fivrr to write you up a sample template type HTACCESS file with simple instructions on how to upload it and use it, as well as what lines to modify and when.
    Signature
    Always Interested in Hearing About Cool SEO Tools and Useful WP Plugins via threads or PMs.

    Interested in Social Media Tools and Content for The Local Marketing Expert clients.
    {{ DiscussionBoard.errors[4173980].message }}
    • Profile picture of the author goodluckdomain
      Hi Davis thanks for your reply its working for me.
      {{ DiscussionBoard.errors[4190656].message }}
  • Profile picture of the author esdavis
    Glad it's working. Sometimes htaccess really is helpful.
    Signature
    Always Interested in Hearing About Cool SEO Tools and Useful WP Plugins via threads or PMs.

    Interested in Social Media Tools and Content for The Local Marketing Expert clients.
    {{ DiscussionBoard.errors[4194249].message }}

Trending Topics