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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:11:36+00:00 2026-05-28T07:11:36+00:00

My site is almost up and running, but in the original code there are,

  • 0

My site is almost up and running, but in the original code there are, for example img src="/design/pic1.png" and so one. On the real server, there is a must dir, web, so the new paths should be img src="web/design/pic1.png" but I don’t want to rewrite all paths.
Is there another option?

  • 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-05-28T07:11:37+00:00Added an answer on May 28, 2026 at 7:11 am

    Depending on your set up, one approach would be to have a constant that dictates your base path which is dependant on your environment.

    For example, suppose in your development environment you’re happy to put all images in $WEB_ROOT . "/design/", but on your production environment it’s $WEB_ROOT . "/web/design/", then you might end up with something like this:

    <?php
    
        // initialise stuff for development
        if(ENVIRONMENT == ENV_DEV) {
    
            define("BASE_PATH", "/");
    
        // initialise stuff for production 
        } elseif(ENVIRONMENT == ENV_PROD) {
    
            define("BASE_PATH", "/web");
    
        }
    
    ?>
    

    Then, in your HTML, you could use this BASE_PATH constant like so:

    <img src="<?=BASE_PATH;?>/design/pic1.png" />
    

    How you decide what is ENV_DEV and ENV_PROD in this example, is entirely up to you.

    One approach would be to detect it based on the domain (using $_SERVER['HTTP_HOST'], which has some caveats).

    Another approach would be to initialise this in your web configuration. Suppose you’re using Apache2, you might use the SetEnv directive.

    In your httpd.conf:

    SetEnv MY_ENVIRONMENT DEV
    

    Which you can access in PHP using:

    <?php
    
        $_SERVER['MY_ENVIRONMENT'];
    
        // or...
    
        getenv("MY_ENVIRONMENT");
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We'll do this on almost every hit to our site. Hosted at Heroku, running
I'm buiding an HTML/jQuery site where almost all the content comes from remote JSON
I've HTML5 version of facebook like button on my site since almost an year
i am working on a recipe site (which is almost finished except this problem)
I'm working on a very small site, with almost zero budget as a favor
I have been working within another question on this site and have almost completed
Almost 20 years ago I built a somewhat dynamic (for the time) web site
Each page of my site has 10 (almost) identical divs, varying only in the
I recently upgraded a site and almost all URLs have changed. I have redirected
I am almost finished building a nameplate site for myself from scratch, both as

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.