【问题标题】:htaccess is not working after moving from XAMPP to LAMP on ubuntu 13.10 (Enable htaccess in apache linux server)在 ubuntu 13.10 上从 XAMPP 移动到 LAMP 后 htaccess 不起作用(在 apache linux 服务器中启用 htaccess)
【发布时间】:2014-04-13 03:34:55
【问题描述】:

我的 CodeIgniter 项目使用 url 在我的 XAMPP 系统上成功运行,

http://localhost/newsfeeds/users/allCategories/

当我将此项目移动到另一个系统时,Ubuntu 13.10 上有 LAMP 服务器。要运行相同的页面,我需要 url,

http://localhost/newsfeeds/index.php/users/allCategories/

我需要 index.php 文件,否则会显示页面未找到错误。

我的 htaccess 文件是,

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

如何在没有 index.php 的情况下在 WAMPP 和 XAMP 服务器上运行相同的项目?

【问题讨论】:

  • 重写模块是否启用?
  • @Rufinus 是的,重写模块已启用
  • .htaccess 文件是否已移至 LAMP 服务器?
  • AllowOverride All 用于 htdocs 目录? error.log 中有任何消息吗?
  • @SverriM.Olsen 是的 .htaccess 文件也在 LAMP 中

标签: php .htaccess redirect ubuntu lamp


【解决方案1】:

我找到了这个问题的解决方案。

在我的服务器中,模式重写已经开启。但是需要在/etc/apache2/apache2.conf 文件上更改一些默认值。以下是我的更改,

首先,找到

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

并将 AllowOverride None 更改为 All 并保存。

然后使用命令启用模式重写(在这种情况下已经启用),

$ sudo a2enmod rewrite

然后重启服务器,

$ sudo /etc/init.d/apache2 restart

运行项目。工作正常。

【讨论】:

    【解决方案2】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 2015-03-20
      • 2015-07-04
      • 2015-07-01
      • 2013-10-12
      • 2017-06-05
      • 1970-01-01
      • 2017-10-19
      • 2010-11-10
      • 1970-01-01
      相关资源
      最近更新 更多