SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast swollenpickles's Avatar
    Join Date
    Jul 2007
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirecting a subdomain to a subdirectory

    I'm wondering if the following is possible - and if it is, how it could be done -

    Can I redirect:

    http://subdomain.domain.com

    to

    http://domain.com/folder/folder

  2. #2
    SitePoint Zealot webhost.uk.net's Avatar
    Join Date
    Jan 2009
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do it using .htaccess rule.. take a look at a sample rule you can set for your subdomain.


    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^blog\.mysite\.com
    RewriteRule ^(.*)$ /blog/$1 [L]

  3. #3
    SitePoint Enthusiast swollenpickles's Avatar
    Join Date
    Jul 2007
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by webhost.uk.net View Post
    You can do it using .htaccess rule.. take a look at a sample rule you can set for your subdomain.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^blog\.mysite\.com
    RewriteRule ^(.*)$ /blog/$1 [L]
    Thanks for that, is it possible for that to be used to redirect to a specific page within the site?

  4. #4
    SitePoint Wizard SiberForum's Avatar
    Join Date
    Dec 2007
    Posts
    1,197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by swollenpickles View Post
    Thanks for that, is it possible for that to be used to redirect to a specific page within the site?
    Yes 301 redirect will allow you to do that. Also if you do not know how call your web host and ask them to install that for you.
    That will be 1 minute work for them.

  5. #5
    Non-Member Jeff Collision's Avatar
    Join Date
    Oct 2010
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by swollenpickles View Post
    Thanks for that, is it possible for that to be used to redirect to a specific page within the site?
    Yes you can

    RewriteRule ^old/URL/path$ new path [R=301,L]

    new path- full path including your domain

  6. #6
    SitePoint Enthusiast swollenpickles's Avatar
    Join Date
    Jul 2007
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SiberForum View Post
    Yes 301 redirect will allow you to do that. Also if you do not know how call your web host and ask them to install that for you.
    That will be 1 minute work for them.
    Thanks, I can do that but I wanted to get my head around how it works as well.

    In the case where the subdomain is/was hosted by host A and the main site (and page within it) is hosted by host B, would you still dump the htaccess file in the root of the main domain?


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
  •