How do I write a .htaccess file to make CodeIgniters URL routing work?

后端 未结 9 1142
死守一世寂寞
死守一世寂寞 2020-12-01 01:13

I\'m running a LAMP environment with CodeIgniter. I want to be able to use its URL pattern, like, http://localhost/controller/function/ID, but by default it has

9条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 01:43

    I had the same issues with CodeIgnitor links images,js,css. It all works now thanks to you guys! I have followed the below steps. consolidated all other comments into my scenario to work. Hope this helps somebody.

    1. changed httpd.conf

      
          AllowOverride All #was "none", but this was all commented out
          Order Deny,Allow
          Deny from all
      
      
    2. created an empty .htaccess file in the htdocs\yoursite(site root) directory and pasted the following.

      DirectoryIndex index.php
      RewriteEngine on
      RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
      

提交回复
热议问题