How to remove “index.php” in codeigniter's path

后端 未结 27 1460
盖世英雄少女心
盖世英雄少女心 2020-11-22 07:17

How do I remove the \"index.php\" sticking out in every path in codeigniter somewhere in the center? I want clean non index.php-fied URLs?

27条回答
  •  鱼传尺愫
    2020-11-22 08:17

    As an .htaccess file, a good option is to use the one provided by the Kohana Framework:

    # Turn on URL rewriting
    RewriteEngine On
    
    # Installation directory
    RewriteBase /
    
    # Protect hidden files from being viewed
    
        Order Deny,Allow
        Deny From All
    
    
    # Protect application and system files from being viewed
    RewriteRule ^(?:application|system)\b.* index.php/$0 [L]
    
    # Allow any files or directories that exist to be displayed directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Rewrite all other URLs to index.php/URL
    RewriteRule .* index.php/$0 [PT]
    

    It's a well thought out .htaccess that just works.

提交回复
热议问题