How to create 301 Redirect for Subdomain

Home Forums BulletProof Security Free How to create 301 Redirect for Subdomain

This topic contains 2 replies, has 2 voices, and was last updated by  Bruce Alfred 4 years ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #15424

    Bruce Alfred
    Participant

    I’ve got a number of 301 Redirects working OK  in my BPS Root htaccess file custom code in the Custom Code Bottom area, as recommended in other support posts. But, I can’t figure out how to get a subdomain to redirect to the new URL which is in the top level domain.  Here’s what I’ve tried for the redirect: Could you please tell me how to setup the redirect so the subdomain can go to the new URL as noted above. I will greatly appreciate any help you can offer.

     RedirectMatch 301 ^harmony.choralartsensemble.org(.*)$ http://choralartsensemble.org/harmony/index.html

    Thanks,
    Bruce

    #15426

    AITpro Admin
    Keymaster

    A subdomain is literally another separate domain and depending on which web host you have the redirect code needed will be different.

    http://forum.ait-pro.com/forums/topic/go-daddy-redirect-htaccess-code-no-longer-working/#post-8362

    This Forum is installed in a folder named “/forum/” and this Forum is a subdomain site with a DNS A record pointing to the “/forum/” folder.  “forums” with an “s” just happens to be the standard/default URL base for BuddyPress/bbPress.  Once again 2 completely different things.

    RedirectMatch 301 ^/forum/forums/topic/alexa-certify-gets-403-errors/$ http://forum.ait-pro.com/forums/topic/alexa-certify/

    I am going to make some assumptions.  You have created a folder named “/harmony” and it is an official subdomain site with a DNS A or CNAME record pointing to /harmony.  You have also created another subfolder named /harmony under your main domain folder name.

    RedirectMatch 301 ^/harmony/(.*)$ http://choralartsensemble.org/harmony/

    The RedirectMatch code would go in the .htaccess file in the subdomain “harmony” .htaccess file and NOT in your main domain’s .htaccess file. You are redirecting from your subdomain site to another website. If you add this RedirectMatch code under your main domain’s .htaccess file you will create an infinite redirect loop since the you have a subfolder under your main domain named /harmony.

    This code below would probably work on other Hosts, but it will not work on Go Daddy Hosting.  This code would go in the subdomain’s .htaccess file ONLY.

    RedirectMatch 301 ^/(.*)$ http://choralartsensemble.org/harmony/
    #15450

    Bruce Alfred
    Participant

    Thanks so much for the quick and helpful response! This is one of the reasons I recommend BPS to anyone looking for WP security!

    -Bruce

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.