.htaccess Help: Make a directory show subdomain content, without redirecting

Discussion in 'Programming' started by norfstar, Sep 19, 2011.

  1. #1
    I am setting up a mobile version of a website. For technical reasons, it needs to be created on a subdomain, mobile.exampledomain.com. However, its content needs to also show up when going to exampledomain.com/mobile/ , and exampledomain.com/mobile/examplefile.html should show mobile.exampledomain.com/examplefile.html . The important point here is that doing a 301 redirect is not wanted, the URL in the browser window needs to remain the /mobile/ directory. Is this possible? If so, can anyone show me some example code?
     
    norfstar, Sep 19, 2011 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Set sub-domain root to be the file which points to "/mobile"

    Like if following is cPanel path,
    ROOT: /home/example/www
    Mobile: /home/example/www/mobile

    set root of mobile.example.com to be /home/example/www/mobile

    This way, you will be able to access the files both the ways.
     
    mastermunj, Sep 19, 2011 IP
  3. norfstar

    norfstar Peon

    Messages:
    1,154
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks mastermunj, but the site is hosted on a Plesk server, not cPanel. When you create a subdomain in Plesk, it forces it to use another directory which is not under the root path for the main website.

    Is there are way I can achieve this using code in .htaccess alone?
     
    norfstar, Sep 21, 2011 IP