【问题标题】:mod_rewrite for Codeigniter on Network Solutions网络解决方案上 Codeigniter 的 mod_rewrite
【发布时间】:2011-12-07 23:29:38
【问题描述】:

我有一个 Codeigniter 2.1 安装在我的本地测试服务器 (XAMPP) 上正常工作,但是当我将它移动到我的网络解决方案主机上的测试子域时,我无法获取 .htaccess 来删除 index.php。我已尝试将重写路径为“/htdocs/test”和/test,但仍然出现以下错误:

内部服务器错误

服务器遇到内部错误或配置错误,无法完成您的请求。

请联系服务器管理员,[未提供地址],并告知他们错误发生的时间,以及您所做的任何可能导致错误的事情。

服务器错误日志中可能会提供有关此错误的更多信息。

此外,在尝试使用 ErrorDocument 处理请求时遇到 500 Internal Server Error 错误。

<IfModule mod_rewrite.c>
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteBase /test

#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]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
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>

我的子域位于 /htdocs/test

谢谢!

【问题讨论】:

  • 你试过RewriteBase /吗?
  • 您能粘贴错误日志中的消息吗?

标签: .htaccess codeigniter


【解决方案1】:

问题很可能出在 httpd.conf 上,如果您无法自行编辑此文件,则您无能为力,只能联系您的主机支持。如果您能够在您的主机上编辑您的 Apache 配置,您可以发布该配置,我们可以为您提供帮助。

模块已加载,但可能不允许您的目录重写,特别是不允许它遵循符号链接,这就是它的工作原理。

【讨论】:

    【解决方案2】:

    首先,确保您在 apache 中安装了 mod_rewrite 模块。杀死 MAIN index.php 文件顶部的脚本:

    <?php die(var_dump(apache_get_modules())); ?>
    

    如果您在未安装它的任何地方都看不到mod_rewrite

    要安装它,请在您的服务器上运行以下命令(如果您有访问权限),

    sudo a2enmod rewrite
    

    然后为我启用了 mod_rewrite,它运行良好。

    如果您没有 root 访问权限,您可能需要联系客户支持,看看他们是否可以为您启用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-02
      • 2011-06-30
      • 2012-10-31
      • 1970-01-01
      • 2011-06-08
      相关资源
      最近更新 更多