在Codeigniter中默认url的形式:http://huangjacky.com/index.php/controller/action/param1/param2,那么如何去掉这个url中的index.php呢?其实我们只需要在根目录创建一个.htaccess文件,定义一下规则即可,.htaccess文件的具体内容如下:

   1:  # Customized error messages.
   2:  ErrorDocument 404 /index.php
   3:   
   4:  # Set the default handler.
   5:  DirectoryIndex index.php
   6:   
   7:  # Various rewrite rules.
   8:  <IfModule mod_rewrite.c>
   9:    RewriteEngine on
  10:    RewriteCond %{REQUEST_FILENAME} !-f
  11:    RewriteCond %{REQUEST_FILENAME} !-d
  12:    RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
  13:  </IfModule>

在nginx下还需要再修改一下这个重定向。等我再研究。

相关文章:

  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2022-02-05
  • 2021-10-24
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
猜你喜欢
  • 2021-06-19
  • 2021-06-19
  • 2022-12-23
  • 2021-08-30
  • 2021-08-10
  • 2021-08-18
相关资源
相似解决方案