【问题标题】:.htaccess for codeigniter on DigitalOcean.htaccess 用于 DigitalOcean 上的 codeigniter
【发布时间】:2016-03-21 07:47:40
【问题描述】:

我的 DigitalOcean 服务器出现问题。我正在使用 Ubuntu。 CodeIgniter 返回给我 404 但在我的本地主机上一切都很好。这是我的 mod_rewrite

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /localhost/x/

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.

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

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.

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

</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule> 

路由和配置都很好。

【问题讨论】:

  • 你在服务器上打开 mod_rewrite 了吗?您使用的是什么版本的 Apache?
  • 是的,我也做了 sudo a2enmod 重写,但仍然无济于事。我用的是 2.4.7 我也重启了 apache2 服务。
  • RewriteBase - 通常是 /
  • 这就是@Svetlio 所说的——你确定有名为localhost 的目录吗?默认情况下,在 DO Ubuntu droplet 上,您的 Web 位置应位于 /var/www/html 中,即 /.htaccess 文件中。

标签: php apache .htaccess codeigniter mod-rewrite


【解决方案1】:

我得到了答案。重命名您的控制器,使其首字母大写。

示例:main.php 到 Main.php

我不知道为什么,但它奏效了!希望对您有所帮助!

【讨论】:

  • 嘿,可以给我一些提示,为什么要使用数字海洋作为数据库的唯一托管,例如 aws 或多于 aws @ Deviant Mark
【解决方案2】:

在我看来你忘记在 Apache .conf 文件中启用 mod_rewrite 使用 sudo a2enmod rewrite 然后 sudo service apache2 restart 启动 mod_rewrite。

更多详情请参阅 Digital Ocean 教程:

https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-ubuntu-14-04

【讨论】:

    猜你喜欢
    • 2023-03-16
    • 1970-01-01
    • 2014-09-23
    • 1970-01-01
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 2019-04-03
    • 2013-11-03
    相关资源
    最近更新 更多