PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 18, 2022

[FIXED] Paths on development and live servers

 February 18, 2022     absolute, development-environment, live, mamp, path     No comments   

Issue

I'm looking for some advice, I currently use MAMP on locahost and have all of my websites in the htdocs folder. I use Codenighter mainly so when adding in paths for links, images etc I use <?php echo base_url(); ?> which is great for using the same code across live and dev.

I was wondering how I can link through to files from within a javascript file and preserve the paths when taking the site up to the live server?

I'm unable to put in absolute paths such as /controller/ as this doesn't work within the MAMP htdocs folder - I have to use /mysite/controller/ instead.

Is there a good way to preserve the paths when working across the two servers?


Solution

You should setup virtualhosts in Apache. By far the easiest way to do this is either get MAMP pro, or get VirtualHost X, the later is what I use. You can certainly setup virtual hosts in the Apache config but VirtualHost X adds the convenience factor.

So for instance if my live site is example.com then I setup a virtual host locally called example.local.



Answered By - bikedorkseattle
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing