Remove index.php of codeigniter

前端 未结 3 565
灰色年华
灰色年华 2020-12-19 22:15

Yes, another one of these. I\'ve tried everything I could find on the search with no luck.

In my httpd.conf (running centos and apache2):



        
相关标签:
3条回答
  • 2020-12-19 22:27

    You need to make sure that in your virtual host you have:

        <Directory "/path...to directory">
            Order allow,deny
            Allow from all
            Allowoverride all
        </Directory>
    
        <IfModule mod_rewrite.c>
            RewriteEngine on
        </IfModule>
    
    0 讨论(0)
  • 2020-12-19 22:29

    Two points of advice:

    1.) Be sure you are saving/editing the .htaccess file into the root of your project folder, and not the .htaccess in your /applications folder. Such that, if my applications folder was at, project/application, don't edit the project/application/.htaccess file. You need your file to be located at project/.htaccess

    2.) Use the following in your .htaccess file:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L]
    
    0 讨论(0)
  • 2020-12-19 22:35

    The rules in the original post (and in the CI user guide) can be used to allow URLs to work without /index.php/ in them, but will NOT remove /index.php/ from existing URLs.

    You can set $config['index_page'] = ''; (removing index.php) in the CI config to remove index.php from CI-generated URLs.

    If the original rules do not work, please give these rewrite rules a try:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [QSA,L]
    
    0 讨论(0)
提交回复
热议问题