CodeIgniter Forums
Live site paths are not working but its working on dev site - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Live site paths are not working but its working on dev site (/thread-33857.html)

Pages: 1 2


Live site paths are not working but its working on dev site - El Forum - 09-10-2010

[eluser]fiktionvt[/eluser]
I am developing on a local host machine and I have a link to a contacts page. This works on my local box but when I deploy it to my live site it does not work. The first assumption is that I have my paths wrong but its not even recognizing my default controller.

I have a default controller named site which is set in the $default_controller variable in the config.

When I am on my local machine I can type in http://localhost:81/ci/index.php/site it will just default to my index() function and show the homepage.


When I am on my live site and i go to http://livesite.com/index.php/site it says file is not found. Can anyone help me with this its really holding up my work. Thanks!


Live site paths are not working but its working on dev site - El Forum - 09-10-2010

[eluser]InsiteFX[/eluser]
Did you change the base_url in application/config.php ?

Also make sure that index.php is pointing to the correct
system and application paths.

InsiteFX


Live site paths are not working but its working on dev site - El Forum - 09-11-2010

[eluser]fiktionvt[/eluser]
I did change the base_url() so my base_url in my config looks like this


Code:
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$config['base_url']    = $root;

I have not changed my index.php file it still points to the 'application' folder and I did not change the name of that folder so that should be working.

In my view the link to the contact page looks like this

Code:
<li id="nav_contact"><a href="&lt;?php echo site_url('site/contact')?&gt;"><span>Contact</span></a></li>

so site is my controller name with the function contact()

When I echo out site_url() on my localhost site it comes up as this: http://localhost:81/ci/index.php

When I echo out site_url() on my live site it cmes up as this http://livesite.com/index.php

I dunno whats wrong everything is working on my dev box. Please any help would be greatly appreciated.


Live site paths are not working but its working on dev site - El Forum - 09-11-2010

[eluser]Buso[/eluser]
Try adding a trailing slash


Live site paths are not working but its working on dev site - El Forum - 09-11-2010

[eluser]fiktionvt[/eluser]
a slash to what


Live site paths are not working but its working on dev site - El Forum - 09-11-2010

[eluser]InsiteFX[/eluser]
Place this at the end of - application/constants.php
Code:
/*
|--------------------------------------------------------------------------
| Document root folders
|--------------------------------------------------------------------------
|
| Author: Phil Sturgeon. [DO NOT REMOVE]!
|
| These constants use existing location information to work out web root,
| etc.
|
*/

// Base URL (keeps this crazy stuff out of the config.php
if (isset($_SERVER['HTTP_HOST']))
{
    $base_url  = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
    $base_url .= '://' . $_SERVER['HTTP_HOST'];
    $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);

    // Base URI (It's different to base URL!)
    $base_uri = parse_url($base_url, PHP_URL_PATH);

    if (substr($base_uri, 0, 1) != '/')  $base_uri  = '/' . $base_uri;
    if (substr($base_uri, -1, 1) != '/') $base_uri .= '/';
}

// Else It's localhost
else
{
    $base_url = 'http://localhost/';
    $base_uri = '/';
}

// Define these values to be used later on
define('BASE_URL', $base_url);
define('BASE_URI', $base_uri);

define('APPPATH_URI', BASE_URI . APPPATH);

// We dont need these variables any more
unset($base_uri, $base_url);

Place this in - application/config.php
Code:
$config['base_url'] = BASE_URL;

InsiteFX


Live site paths are not working but its working on dev site - El Forum - 09-11-2010

[eluser]fiktionvt[/eluser]
Thanks for the help, this however still did not work. I don't think the issue is with the paths as much as it is that I can not access my controller. For some reason I can no type in my live site livesite.com/index.php/site , where site is my controller it says the file is not found.

I can do this on my local machine localhost:81/ci/index.php/site and that will bring my to my homepage. This is really frustrating I can not figure out what is going on.


Live site paths are not working but its working on dev site - El Forum - 09-11-2010

[eluser]InsiteFX[/eluser]
If this is a Parked Domain it will display their
page not yours!

If it is parked on your domain then it will display

If it is parked on your hosting provide they send it
to their own page not yours!

InsiteFX


Live site paths are not working but its working on dev site - El Forum - 09-11-2010

[eluser]fiktionvt[/eluser]
So I decided to download a fresh copy of code igniter and create a simple example of a link on my site just to see if I can get it to work. So the code that I have put in the constants.php file is this.

Code:
// Base URL (keeps this crazy stuff out of the config.php
if (isset($_SERVER['HTTP_HOST']))
{
    $base_url  = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
    $base_url .= '://' . $_SERVER['HTTP_HOST'];
    $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);

    // Base URI (It's different to base URL!)
    $base_uri = parse_url($base_url, PHP_URL_PATH);

    if (substr($base_uri, 0, 1) != '/')  $base_uri  = '/' . $base_uri;
    if (substr($base_uri, -1, 1) != '/') $base_uri .= '/';
}

// Else It's localhost
else
{
    $base_url = 'http://localhost/';
    $base_uri = '/';
}

// Define these values to be used later on
define('BASE_URL', $base_url);
define('BASE_URI', $base_uri);

define('APPPATH_URI', BASE_URI . APPPATH);

// We dont need these variables any more
unset($base_uri, $base_url);

Then in my config file I have

Code:
$config[base_url] = BASE_URL;

So what I have done in the welcome_message.php file I have inserted this

Code:
<a href="&lt;?php echo site_url('welcome/test')?&gt;"><span>Home</span></a>

So there is a link to a view called test.php. IT just prints TEST!! when it works. IT works on my local machine but when I upload it to my live site it gives me an error of file not found.

You can see the result if you go to the site www.theprizeshark.com that is where I am trying to put it.

I am thinking it is maybe how I am uploading it to my server? When I log into my site through ftp I have these CI files

system
index.php

but on my local machine in my WWW directory it looks like this

ci
|-system
|-index.php

I dunno if this makes a difference but it loads the welcome_message.php page okay so I am sure that its working. Thanks for the help


Live site paths are not working but its working on dev site - El Forum - 09-11-2010

[eluser]fiktionvt[/eluser]
Do I need to modify my .htaccess file or my php.ini file or anything? This is driving me nuts.