Welcome Guest, Not a member yet? Register   Sign In
Upgraded to 3... can't access pages
#1

(This post was last modified: 01-06-2016, 05:42 AM by baazil1.)

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.
Reply
#2

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.
Reply
#3

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

http://www.codeigniter.com/user_guide/ge...x-php-file
Reply
#4

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?
Reply
#5

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).
Reply
#6

(This post was last modified: 01-06-2016, 08:29 AM by PaulD. Edit Reason: Crossed with previous post )

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.
Reply
#7

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

Appreciate all the help!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB