SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Twitter: @SprightlyMedia Manpasand's Avatar
    Join Date
    Feb 2005
    Location
    Internet
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Subdomain 301 Redirect

    How subdomain 301 redirect to main domain via .htaccess and where should place that .htaccess file?
    e.g. http://sub.domain.com to http://www.domain.com/new

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,426
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    the .htaccess file should go in the root directory of the subdomain.

    redirect 301 http://sub.domain.com http://www.domain.com/new

  3. #3
    Twitter: @SprightlyMedia Manpasand's Avatar
    Join Date
    Feb 2005
    Location
    Internet
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have already tried and checked once again after your response but
    http://SUB.domain.com is redirecting to http://www.domain.com/SUB NOT
    http://www.domain.com/NEW

  4. #4
    Twitter: @SprightlyMedia Manpasand's Avatar
    Join Date
    Feb 2005
    Location
    Internet
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have done it with following line

    redirect 301 /SUB/ http://www.domain.com/NEW/

    and put the .htaccess file in subdirectory root.

    Thanks

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,644
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Man,

    Subdirectory Root is the correct location - Stymiee was assuming that you had that directed at the Main domain's root (as most people do - while they should be redirecting to the actual root of the subdomain).

    Personally, though, I'd use mod_rewrite to preserve the original {REQUEST_URI} and {QUERY_STRING}. If you need help with that code, please let us know the relative path between the two domains and directories, etc.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    Twitter: @SprightlyMedia Manpasand's Avatar
    Join Date
    Feb 2005
    Location
    Internet
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn
    If you need help with that code, please let us know the relative path between the two domains and directories, etc.
    DK
    Yes, please help me for that code because I don't know how to do it.
    Thanks

  7. #7
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,644
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Man,

    Okay, will do as soon as I know where the subdomain's DocumentRoot is relative to the domain's DocumentRoot.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •