Reputation: 238
I'm setting up my first personal codeigniter project and my .htaccess file is this:
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /madrigal/
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
I have set up my config.php file to $config['index_page'] = ''; and $config['uri_protocol'] = 'REQUEST_URI'; but when I go to my controller /admin/, index isn't ran unless I type out "/index" at the end of the URL. Is my htaccess file disallowing that?
Thanks for any help
Upvotes: 1
Views: 1213
Reputation: 5813
You can check the following link...
http://ellislab.com/codeigniter/user-guide/general/urls.html
or,
Cannot remove index.php from CodeIgniter URL
Upvotes: 1
Reputation: 3641
You can easily remove this index.php by using a .htaccess file with some simple rules.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|img|js)
RewriteRule ^(.*)$ /index.php/$1 [L]
In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file. You can read the documentation here
$config['index_page']
is the configuration for your default page to call and not for removing index.php in your URI
Upvotes: 0