【问题标题】:Remove index.php in codeigniter on ubuntu using htaccess file使用 htaccess 文件在 ubuntu 上的 codeigniter 中删除 index.php
【发布时间】:2013-08-21 19:17:48
【问题描述】:

使用安装在 Windows 7 上的 Apache2,我使用下面的 htaccess 配置从 codeigniter url 中删除 index.php:

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

有人可以告诉为什么上面的配置在 ubuntu 上不起作用。 我已经使用 sudo a2enmod rewrite 启用了 mod 重写。谢谢

【问题讨论】:

标签: .htaccess codeigniter mod-rewrite


【解决方案1】:

这可能是因为 ubuntu 服务器设置为传递 PATH_INFO,这意味着您不需要查询字符串。您可能只需从规则中删除 ? 即可,它应该可以工作:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-07
    • 2019-04-06
    • 2015-03-09
    • 2023-03-16
    • 1970-01-01
    • 2016-05-13
    • 2014-11-25
    • 2018-09-17
    相关资源
    最近更新 更多