codeigniter url handling to remove index.php and method name

前端 未结 2 903
北荒
北荒 2021-01-17 01:01

hi i am using codeigniter first time and i have to manage my URL to view URL without index.php/controller so how can i write ht access and where i keep it my folder structur

相关标签:
2条回答
  • 2021-01-17 01:22

    put this code in your .htaccess file.

    RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule .* index.php/$0 [PT,L] 
    
    0 讨论(0)
  • 2021-01-17 01:28

    Open config.php and do following replaces

    $config['index_page'] = "index.php"
    

    to

    $config['index_page'] = ""
    

    Just replace

    $config['uri_protocol'] ="AUTO"
    

    to

    $config['uri_protocol'] = "REQUEST_URI"
    

    AND IN HTACCESS FILE put following code

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