【问题标题】:htaccess in codeigniter to clear index.php at url在 codeigniter 中的 htaccess 以清除 url 处的 index.php
【发布时间】:2013-08-18 11:01:44
【问题描述】:

我是 htacces 的新手.. 我有这样的文件htaccess

    Options -Indexes

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ index.php?/$1 [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

我在没有 index.php 的情况下这样调用 url,它可以工作

http://localhost/url/

但是当我尝试打电话时

http://localhost/url/controller/

http://localhost/url/controller/method/

返回 xampp 主页的页面。

那我该怎么办?我想要没有 index.php 的 url。

非常感谢您的每一个建议。

【问题讨论】:

  • 它不起作用,我得到 404 Page Not Found The page you request was not found.
  • 您还有其他 htaccess 文件吗?具体来说,“控制器”目录中有没有?
  • 您的站点在url 文件夹下还是根目录下?
  • 请看我的回答stackoverflow.com/a/18230894/1613335,也许对你有帮助
  • 不,我只有一个 htaccess 文件。

标签: .htaccess codeigniter mod-rewrite


【解决方案1】:

看起来你需要一些简单的东西,比如:

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|media|favicon\.ico|ipadicon\.jpg)
RewriteRule ^(.*)$ /index.php/$1

【讨论】:

    猜你喜欢
    • 2018-09-17
    • 1970-01-01
    • 2015-03-09
    • 2019-04-06
    • 1970-01-01
    • 1970-01-01
    • 2017-05-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多