1

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

0

2 Answers 2

1

You can check the following link...

http://ellislab.com/codeigniter/user-guide/general/urls.html

or,

Cannot remove index.php from CodeIgniter URL

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, but the CI user guide on this is actually outdated, which is why I'm here asking.
please take a look at the second link in my answer. This is the way i do with my codeigniter app.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.