CodeIgniter removing index.php from url

前端 未结 30 1438
[愿得一人]
[愿得一人] 2020-11-21 11:51

My current urls look like this [mysite]index.php/[rest of the slug].
I want to strip index.php from these urls.

mod_rewrite

30条回答
  •  情话喂你
    2020-11-21 12:03

    This works for me. Tested in codeigniter 3.1.11, PHP 5.6.40 I use a virtualhost in my apache2 config in testing server.

    
         ServerAdmin webmaster@dummy-host2.example.com
         DocumentRoot (__DIR__)
         ServerName mydomain
         ##ErrorLog "logs/dummy-host2.example.com-error.log"
         ##CustomLog "logs/dummy-host2.example.com-access.log" common
         
            Require all granted
            AllowOverride All
       
    
    

    And /.htaccess content

        
           RewriteEngine On
           RewriteCond %{REQUEST_FILENAME} !-f
           RewriteCond %{REQUEST_FILENAME} !-d
           RewriteRule ^(.*)$ index.php/$1 [L] 
        
    

提交回复
热议问题