• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Upgraded to 3... can't access pages

I've upgraded to CodeIgniter 3 and followed the guide, changed all my controllers to Ucfirst. I only have 5 controllers, this isn't a huge site.

My config is as such:

$config['base_url'] = 'http://www.eldermaltreatment.com/'
$config['index_page'] = '';
$config['uri_protocol']    = 'AUTO';

I can easily access www.eldermaltreatment.com, but cannot access www.eldermaltreatment.com/about.

404 everywhere.

Any suggestions?

EDITED to remove $_SERVER... based off NARF's suggestion.

Not for the 404 problem, but don't just shove $_SERVER['HTTP_HOST'] in your base_url - that makes you vulnerable to Host header injections, possibly leading to a number of XSS vulnerabilities.

If you have the index_page set, you should be accessing www.example.com/index.php/controller


I do not have the index_page set. Why would anyone want a URL with index.php stuck right in the middle of it? 

This could be a .htaccess issue. My file:

# Make sure directory listing is disabled
Options +FollowSymLinks -Indexes
RewriteEngine on

# Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]

When I do add in the index.php into the URL (manually go to URL address and type http://www.eldermaltreatment.com/index.php/about), the page comes up, but none of the style sheets are linked and the page is left unstyled. 


See if you have mod_rewrite installed/enabled on Apache, as well as if the AllowOverride option is turned on for the virtual host (if it's not you can't do anything with .htaccess).


Your css files are (if you inspect the source) relative links. Not knowing how you generate your URL, if you are using base_url then there is an issue with that, otherwise you just need the / at the start (one of your stylesheets is listed as .php too).

The working with index and not without index is probably a .htaccess issue, but not being anything more than an amateur at .htaccess (its all voodoo to me) here is my version that I use that works on virtually every site I do:

DirectoryIndex index.php

RewriteEngine on
RewriteBase /portal/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]

<FilesMatch ".(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"

In fairness it looks just like yours, but with some extra bits in it (that I am not sure are needed or indeed what they do) but it works for me.

Hope that helps,


PS Crossed with Narf's previous post and of course, Narf is right, make sure your .htaccess is working.

Fantastic! It seems the mod-rewrite and AllowOveride All did the trick.

Appreciate all the help!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.