【问题标题】:htaccess is not working after changing server with codeigniter使用 codeigniter 更改服务器后 htaccess 无法正常工作
【发布时间】:2016-01-15 06:29:44
【问题描述】:

我正在使用带有 .htaccess 的 codeigniter

在旧服务器中,我在 .htaccess 文件中有以下规则

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^transaction\.php$ index.php/printer_api/transaction/%1/%2/%3/%4/%5/%6/%7/%8 [L]
RewriteRule ^getlist\.php$ index.php/printer_api/getlist [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

它工作正常。 但是在将网站移动到新服务器后,URL .htaccess 无法正常工作 它显示“未指定输入文件”

在网上搜索后,我找到了一个解决方案: 更改最后一行的规则:

RewriteRule ^(.*)$ index.php/$1 [L,QSA]

to(在 index.php 之后添加额外的 ?):

RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

这解决了使用 codeigniter 重写通用 URL。

但我仍然对以下特定于单独 URL 的部分有疑问:

RewriteRule ^transaction\.php$ index.php/printer_api/transaction/%1/%2/%3/%4/%5/%6/%7/%8 [L]
RewriteRule ^getlist\.php$ index.php/printer_api/getlist [L]

在第一个 URL 中最多有 8 个参数(但参数的数量可能因情况而异 在第二个 URL 中没有参数。 但这些 URL 在新服务器中不起作用。

现在任何人都可以帮助使这两个规则起作用。

【问题讨论】:

    标签: apache .htaccess codeigniter mod-rewrite url-rewriting


    【解决方案1】:

    不确定它是否会起作用,但您是否尝试过与index.php 类似的解决方案?比如:

    RewriteRule ^transaction\.php$ index.php?/printer_api/transaction/%1/%2/%3/%4/%5/%6/%7/%8 [L]
    RewriteRule ^getlist\.php$ index.php?/printer_api/getlist [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-07
      • 1970-01-01
      • 1970-01-01
      • 2017-12-09
      • 1970-01-01
      • 2017-01-31
      • 2017-04-11
      • 2019-08-04
      相关资源
      最近更新 更多