Welcome Guest, Not a member yet? Register   Sign In
Moving from localhost to web server
#1

Hello,

I've recently been following a few tutorials for Codeigniter and have the basics down pretty well. I've been working using WAMPserver throughout the day and just went to put my CI folder onto my webspace to test it out.

I've had a play around and I've got the homepage working as it should but having some trouble with links to other pages, I'm pretty sure its to do with file paths but could do with a hand.

The website is http://srbportal.com/SrbPortal/ (/SrbPortal being the CI file). I've removed the base URL from the config which allowed the page to load properly but unfortunately none of the linking pages work anymore.

The linking page works if gone to directly using the link http://srbportal.com/SrbPortal/index.php/site/about - I had previously removed the "index.php" using .htaccess while using the localhost. Is there something different I need to put when it's on a webhost?

Many thanks!

Scott
Reply
#2

(This post was last modified: 02-08-2015, 08:31 PM by twpmarketing. Edit Reason: added comment )

Two things to check first:

1)  Your config.php file and in that file, the $config['base_url'] setting and immediately below that the $config['index_page'] setting.

2) Your routes.php file and it's $route['default_controller'] setting.

Since you tried removing the index.php controller from the URL via .htaccess, there may be differences in .htaccess that are causing trouble, please check it also.

Looking at your site, I see that methods in your 'site' controller are expecting to receive another piece of information, the "input file", possibly a filename?  Can't tell without seeing the rest of the code but check your code for something that is NOT available.

When I view the page html, I see that your main menu is using a mixture of relative and full url paths.  Since each menu item calls the same controller ('site'), this is possibly a problem?  Again, I can't tell more without seeing the underlying php code.
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply
#3

(This post was last modified: 02-08-2015, 10:50 PM by John_Betong. Edit Reason: added error checking )

In my index.php file I test and set a constant "LOCALHOST" which is used to cater for different database configuration settings and file paths, etc.

PHP Code:
<?php // index.php
define('LOCALHOST''localhost' === $_SERVER['SERVER_NAME']);
define('DEBUG'4); // 0 is false 
...
...



<?
php // footer.php
if(LOCALHOST// GOOGLE Analytics ?>
 <script type='text/javascript' src="<?=base_url().VIEWPATH;?>js/__google_analytics.js" ></script>
<?php endif;?>


Using this technique eliminates the problem of having two separate locahost and online files.


Edit:
Most problems are usually shown by setting the following:

PHP Code:
<?php // config/config.php

if(DEBUG) {
 
error_reporting(-1); // show all errors
 
ini_set('display_errors' true);
}

$config['log_threshold'] = DEBUG// for production best set to 1
$config['log_path'] = APPPATH   // ORIGINAL -- 1; 
Reply
#4

Why do all of that when CI has environments?
Reply
#5

Check the capitalization of the names of your application's files and directories. Windows tends to be forgiving about the case of your filenames, but Linux is not. Additionally, make sure your files follow CI's naming requirements, which are more strictly enforced in a case-sensitive environment.
Reply
#6

(02-09-2015, 09:43 AM)Cro NiX Wrote: Why do all of that when CI has environments?

Force of habit I suppose. This ENVIRONMENT constant was not available in earlier CI Versions

I used this technique way back using CI 1.7. When upgrading to later versions it still worked a treat just by changing the index.php->$system_path variable to the latest version. (I wished Laravel was as simple to switch versions).

When developing a new application I will endeavour to use this latest feature. 
Reply
#7

(02-09-2015, 11:30 AM)mwhitney Wrote: Check the capitalization of the names of your application's files and directories. Windows tends to be forgiving about the case of your filenames, but Linux is not. Additionally, make sure your files follow CI's naming requirements, which are more strictly enforced in a case-sensitive environment.

Errors will be logged when the following configuration item is set:


PHP Code:
$config['log_threshold'] = 4 // All Messages 
Reply
#8

(02-08-2015, 02:38 PM)Scottio Wrote: Hello,

I am facing the same problem as described by you. Please tell me how to solve this problem, if you have solved it already. 

Thanks!

DawlatXai
Reply
#9

(02-08-2015, 02:38 PM)Scottio Wrote: Hello,

I've recently been following a few tutorials for Codeigniter and have the basics down pretty well. I've been working using WAMPserver throughout the day and just went to put my CI folder onto my webspace to test it out.

I've had a play around and I've got the homepage working as it should but having some trouble with links to other pages, I'm pretty sure its to do with file paths but could do with a hand.

The website is http://srbportal.com/SrbPortal/ (/SrbPortal being the CI file). I've removed the base URL from the config which allowed the page to load properly but unfortunately none of the linking pages work anymore.

The linking page works if gone to directly using the link http://srbportal.com/SrbPortal/index.php/site/about - I had previously removed the "index.php" using .htaccess while using the localhost. Is there something different I need to put when it's on a webhost?

Many thanks!

Scott


Remove the index.php from config.php like this:

PHP Code:
$config['index_page'] = ''


Change you .htaccess with this:

PHP Code:
<IfModule mod_rewrite.c>

 
 Options +FollowSymLinks
  RewriteEngine on

  
# Send request via index.php
 
 RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond 
%{REQUEST_FILENAME} !-d
  RewriteRule 
^(.*)$ index.php?/$[L]

</
IfModule
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro
Reply




Theme © iAndrew 2016 - Forum software by © MyBB