How to remove public/index.php/ from url in Codeigniter 4

前端 未结 9 881
有刺的猬
有刺的猬 2021-02-02 18:00

I want normal URL like www.sample.com/controller not www.sample.com/public/index.php/controller.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCo         


        
9条回答
  •  抹茶落季
    2021-02-02 18:22

    1. Set up Virtual hosts (if you haven't already), but make sure to point to /public directory (xampp example):

    ServerAdmin webmaster@example.com
    ServerName example.com
    DocumentRoot "path-to-project/public"
    
        Order allow,deny
        Allow from all
        AllowOverride All
        Require all granted
    
    

    1. Do not touch any .htaccess file in default CI4 distribution
    2. Edit app/Config/App.php - $baseURL = 'http://www.example.com/'; $indexPage = '';

提交回复
热议问题