Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8478039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:38:04+00:00 2026-06-10T18:38:04+00:00

I have this site that I need to find the root folder / plus

  • 0

I have this site that I need to find the root folder / plus the actual folder its works out of.

My problem here is that during development i have the folder with in my local server that in turn is with in its own folder:

Then online I then have the development site within a folder, so it can all be tested before the live production etc.

LOCAL SERVER:
localhost/mytestSiteA/…

LIVE SERVER TEST FOLDER:
http://www.asite.com/devbuild/….

Now I can retrieve the root via the

    document.location.hostname 

But i need then to add the folder name after this so that I can load in content etc when in developement mode.

LOCAL SERVER

 document.location.hostname + '/mytestSiteA/'

LIVE TEST SITE

 document.location.hostname + '/devbuild/'

But my issue is, is there an easy way to gain this inner folder rather than setting up variables determined on whether in local dev, live dev or live mode, as can be a pain, and would be nice to gain the current inner folder dynamically rather that manually changing etc so that I can add my paths correctly.

Also would help as if I have a folder within this that also loads in js script it can obtain its full path.

LOCAL SERVER:
localhost/mytestSiteA/subsection/…

LIVE SERVER TEST FOLDER:
http://www.asite.com/devbuild/subsection/…

I hope I have made this as easy to understand and put across.
Si

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:38:06+00:00Added an answer on June 10, 2026 at 6:38 pm

    try to switch

    switch (document.location.hostname)
    {
            case 'asite.com':
                              var rootFolder = '/devbuild/'; break;
            case 'localhost' :
                              var rootFolder = '/mytestSiteA/'; break;
            default :  // set whatever you want
    }
    

    and then use

    var root = document.location.hostname + rootFolder;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that has an Rss feed, and this feed is consumed
I have a file hosting site that's using this script MFHS . I want
I have a web site that contains an HTML form, in this form I
I have a route that is suppose to match something like this localhost:3000/site/admin and
I have an XML document that matches our site navigation something like this: <page
we have this old application that we need to port to a new machine
I have been looking everywhere but I can't find a site that shows how
I have a small problem, looked here & other forums, but could not find
I have this membership site setup on my local machine using the ASP.NET membership
I have searched this site and Google and even though the idea is pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.