1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Redirect sub domains to sub folders

Discussion in 'Site & Server Administration' started by Blue DIamond STL, May 15, 2019.

  1. #1
    I am in the process of changing the architecture of a site from:

    subdomain1.domain.co.uk/product_a
    subdomain2.domain.co.uk/product_b
    subdomain3.domain.co.uk/product_c

    to:

    www.newdomain.co.uk/brand_a/product_a
    www.newdomain.co.uk/brand_b/product_b
    www.newdomain.co.uk/brand_c/product_c

    Basically, the subdomains are brand names, I have always hated the architecture so changing to a better subfolder system.
    SEMrush
    When I go live I know I need to use .htaccess for my permanent redirections, but for the life of me I can't figure out how it's written, anyone any ideas?

    It's a WordPress/woo site.

    Thanks in advance
     
    Last edited by a moderator: May 15, 2019
    Blue DIamond STL, May 15, 2019 IP
    SEMrush
  2. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #2
    This will redirect subdomain1.domain.co.uk/product_a to www.newdomain.co.uk/brand_a/product_a


    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^subdomain1.domain.co.uk
    RewriteRule ^(.*)$ http://www.newdomain.co.uk/brand_a/$1 [L,NC,QSA]
    Code (markup):

    A more general rule if the subdomain and the subdirectory are sharing the same name:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(.*)\.domain\.co\.uk
    RewriteRule ^(.*)$ http://www.newdomain.co.uk/%1/$1 [L,NC,QSA]
    Code (markup):
     
    RoseHosting, May 26, 2019 IP