【问题标题】:.htaccess not working after updating ubuntu.htaccess 在更新 ubuntu 后无法正常工作
【发布时间】:2017-06-27 05:19:44
【问题描述】:

我最近将我的 ubuntu 从 14.04 更新到 16.04。 我正在使用 codeigniter。

在更新之前,所有项目都运行良好,但现在没有一个项目正在使用 .htaccess 。我正在使用 htaccess 从 url 中隐藏 index.php。

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

这是我在项目根文件夹中的 htaccess 文件。

【问题讨论】:

  • 请定义不工作
  • 定义@Capsule
  • 是否启用了 mod_rewrite?
  • mod_rewrite 是实际处理重写的 Apache 模块。在您的服务器上(通过 ssh),尝试:sudo a2enmod rewrite && sudo apache2ctl restart 并再次尝试您的网站。
  • 您可能需要启用重写模块并重新启动服务器。看到这个答案:stackoverflow.com/a/14807463(从第 3 步开始)

标签: php apache .htaccess codeigniter ubuntu


【解决方案1】:

这就是答案,cmets 中 Benson 的 Givan。

您可能需要启用重写模块并重新启动服务器。看到这个答案:https://stackoverflow.com/a/14807463

【讨论】:

    【解决方案2】:

    index.php 之后你可能会错过?。

    改变你的

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

    到

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

    【讨论】:

      猜你喜欢
      • 2017-05-23
      • 2014-11-15
      • 2019-08-10
      • 2014-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多