Removing index.php - official guide not working (code igniter)

后端 未结 3 494
耶瑟儿~
耶瑟儿~ 2021-01-28 02:38

I am trying to remove the index.php in the url for Code Igniter. According to the official guide, I should add the following code to the .htaccess file.

RewriteE         


        
相关标签:
3条回答
  • 2021-01-28 03:00

    Make this changes to config file

     $config['base_url'] = 'http://localhost/projectname/';
     $config['index_page'] = '';
    

    Then in ur .htaccess try

     DirectoryIndex index.php
     RewriteEngine on
     RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ ./index.php?$1 [L,QSA] 
    

    Also make sure that you have mod_rewrite enabled in your apache configuration

    The .htaccess file should be in root directory of your project, ie outside application folder

    0 讨论(0)
  • 2021-01-28 03:12

    I'm assuming that whatever folder that http://localhost/projectFolder/CodeIgniter/ maps to is your docroot and that the .htaccess file is inside that directory.

    If that is the case, then your code is correct - so it's a matter of your apache config. Make sure that you are allowing .htaccess files by changing the Directory block - AllowOverride All.

    Take a look at this page for help doing that.

    0 讨论(0)
  • 2021-01-28 03:21

    I think the following code should work for you

    RewriteEngine on
    RewriteCond $1 !^(index\.php|css|js|public|themes|captcha|robots|documents|\.txt)
    RewriteRule ^(.*)$ /projectFolder/index.php/$1 [L]
    

    Hope this helps you.

    0 讨论(0)
提交回复
热议问题