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 9005993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:17:43+00:00 2026-06-16T01:17:43+00:00

I need to take an existing website and place it as a subdirectory of

  • 0

I need to take an existing website and place it as a subdirectory of another existing website. For example, I have http://www.website1.com and http://www.website2.com and I need to put website2 in website1 like this: http://www.website1.com/website2/. It should be noted I’m using IIS to host these websites.

I’ve actually run into this multiple times and I was wondering if there was a good way to write my links so I could easily drop a website anywhere and not have to reformat every link. I use two main paths – one for my root, and one for an includes folder outside my root. My first thought was to have two path variables in PHP for these paths, but then it couldn’t go in my external js and css files. I don’t want to turn those into php files if I can help it because of the caching complications that creates.

Anyway, does anyone else have a good solution for this? How have you handled it in the past?

  • 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-16T01:17:45+00:00Added an answer on June 16, 2026 at 1:17 am

    Here’s what I ended up doing:

    For the items under my root directory, I used pure relative paths. So for example, when I access an image in my image folder, the link depends on how deep the page I’m on in the directory structure is:

    <img src='./images/myImg.png'/> <!-- in root dir -->
    <img src='../images/myImg.png'/> <!-- 2 levels deep -->
    <img src='../../images/myImg.png'/> <!-- 3 levels deep -->
    

    This is not ideal as I have to think about where every link is in relation to the file I’m in and if I change the location of the images folder or the file, I need to change every link. The positive though is as long as I don’t start changing my directory structure, I can place this folder at any level and it will work without change. For example, I can do:

    www.website2.com
    www.website1.com/website2/
    www.website1.com/sub-directory/website2/
    

    And it works without any changes to the links.

    For the items in my includes folder that is outside the root folder, I had to do it a little differently. For those, I used relative links in PHP, which I learned more about here http://yagudaev.com/posts/resolving-php-relative-path-problem/. He describes a few different options, but in the end, I created a global variable like thus:

    $includesPath = $_SERVER['DOCUMENT_ROOT'] . "/../myProductsIncludes/";
    

    This will look for the includes folder in the same folder as the root folder. If I need to adjust the location of the includes folder, I just change the link in this one variable. Then whenever I write a url to a file in the includes folder, I prepend the global var, like this:

    include $includesPath . "classes/myClass.php";
    

    This is all rather elementary stuff, and has some drawbacks so I wouldn’t use it for every project, but it works great if I have a project that I don’t know where it will end up in a directory structure (for example, if I’m contracting for a client). So for example, if I’m giving this to a client, he can drop the contents of my root folder into any subdirectory on his website and place the includes folder in the same folder as the root of his website (or just change that one variable if he wants to store it somewhere else), and it all works without changing a link.

    If anyone has a different way of doing this, or any improvements to my way, I’d love to hear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to take a url, /ServiceSearch/r.php?n=blahblah, and have it go to /search/blahblah/ so
I need to take an image and place it onto a new, generated white
I often have a need to take a list of objects and group them
I need to write a program that will take a existing local windows user,
What all care I need to take when merging an existing Asp.Net 3.5 application
I need to take existing classes for an iPhone application and store them in
We have a situation where we need to take a tag of our project
I need to take an existing xml file, and modify just a few attributes
I need to take an existing winforms application and drop into an event tracing
I have a need to take a time period, e.g. a week and break

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.