Welcome Guest, Not a member yet? Register   Sign In
Unable to get routing to work correctly
#1

I have a site that I am using to learn PHP and CodeIgniter. I have an .htaccess file 

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

and an entry in the routes.php $route['Person'] = 'person';
that should remove the index.php from the URL.

This URL works http://codeigniter/index.php/Person
This URL doesn't http://codeigniter/Person

I have set the base URL $config['base_url'] = 'http://codeigniter/';
and removed the index_page $config['index_page'] = '';

What am I missing? I am new to routing and apache.

I am using WAMP 64 and the rewrite_module is on.

THanks
Reply
#2

I suspect the .htaccess is the issue.
Mine is like this:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

Setting a route like $route['Person'] = 'person' doesn't make much sense. It tells CI to route to the controller 'person' when the url is 'http://mywebsite.com/person'. It will behave like that without the route too.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB