CodeIgniter Forums
Upgraded to 3... can't access pages - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Upgraded to 3... can't access pages (/thread-64026.html)



Upgraded to 3... can't access pages - baazil1 - 01-05-2016

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:

Code:
$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.


RE: Upgraded to 3... can't access pages - Narf - 01-05-2016

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.


RE: Upgraded to 3... can't access pages - mr_pablo - 01-06-2016

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

http://www.codeigniter.com/user_guide/general/urls.html#removing-the-index-php-file


RE: Upgraded to 3... can't access pages - baazil1 - 01-06-2016

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:

Code:
# 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. 

Thoughts?


RE: Upgraded to 3... can't access pages - Narf - 01-06-2016

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).


RE: Upgraded to 3... can't access pages - PaulD - 01-06-2016

Hi,

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:

Code:
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 "*"
</IfModule>
</FilesMatch>

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,

Paul.

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


RE: Upgraded to 3... can't access pages - baazil1 - 01-06-2016

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

Appreciate all the help!