【问题标题】:how to write .htaccess for codeigniter version 2.2?如何为codeigniter 2.2版编写.htaccess?
【发布时间】:2015-06-03 08:09:11
【问题描述】:

我使用 CI2.2 完成了一个示例项目。我尝试了很多方法从 url 中删除 Index.php。但它不起作用。请帮我摆脱这个。

我的文件夹结构:localhost/Myproject

请帮帮我

【问题讨论】:

标签: php apache .htaccess codeigniter mod-rewrite


【解决方案1】:

把它放在你的 Htaccess 文件中

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

【讨论】:

  • 您似乎没有从 apache 启用 mod_rewrite 更改您的 apache 配置文件并重新启动 apache。
  • 你可以 echo phpinfo() 并在 apache2handler 部分下检查 mod_rewrite 模块是否加载。
  • RewriteCond $1 上的 RewriteEngine !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] --IfModule> 我只是像这样更改了我的 htaccess 文件。但它总是显示错误 404。
猜你喜欢
  • 2016-03-17
  • 1970-01-01
  • 2011-12-03
  • 2012-09-10
  • 2014-04-09
  • 1970-01-01
  • 2017-11-19
  • 2012-11-28
  • 1970-01-01
相关资源
最近更新 更多