Welcome Guest, Not a member yet? Register   Sign In
CI development site executing code from the production site
#1

[eluser]tomgkelly[/eluser]
I use windows based tools for development, but most of my production sites reside on Linux servers, so I have a Linux box networked locally that I use as a development server. I developed a small temporary site (using CI) on a production server (Linux) as a place holder until site requirements were ironed out.

After I had a full set of requirements I was ready to flesh out the site, so I decided to download the code from the production site to my development Linux box. After editing the config and routes files I could access the site on my development box from my windows box using and internal URL. Everything seemed to be working fine. I could modify code, hit the browser refresh button and verify the changes.

The page in question has about three places that use the 'site_url' helper, one of which is a Nav link (
Code:
<a href=" &lt;?= site_url('home') ?&gt;">
). Clicking this nav link should reload the current page ('home page'), but instead it loads the corresponding page on the production site.

After poking around some, I discovered that the local development app is loading the config file from the Production site and not the local file.

I haven't delved into the intricacies of CI, but this seems to be a bit strange to me .... anyone have any ideas?

Tom
#2

[eluser]Phil Sturgeon[/eluser]
This will be due to your base_url being set to the production URL. There are many solutions and quick-fixes to solve this which will probably all be posted here and argued over as usual, but my favourite is the following.

In /application/config/config.php set the base_url like so:

Code:
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/';

That means whatever server you use to access the site will continue to be used within all your links.
#3

[eluser]tomgkelly[/eluser]
[quote author="pyromaniac" date="1229536089"]This will be due to your base_url being set to the production URL. There are many solutions and quick-fixes to solve this which will probably all be posted here and argued over as usual, but my favourite is the following.

In /application/config/config.php set the base_url like so:

Code:
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/';

That means whatever server you use to access the site will continue to be used within all your links.[/quote]

That's part of the problem. The app isn't looking at the local config.php file, it's looking at the production site config file. I can effect all kinds of changes by modifying the production site config file, but changing the local config file has no effect at all. Weird!


My local 'base_url' is set to localhost which works fine when initially accessing the local site. Viewing the source shows all links pointing to the local site (localhost), but clicking one of the links (i.e. the 'Home' link) brings up a copy of the 'Home' page from the production server. Looking at the source code now shows the production site URL in all the links.




Theme © iAndrew 2016 - Forum software by © MyBB