【问题标题】:static Codeigniter application on subdomain子域上的静态 Codeigniter 应用程序
【发布时间】:2013-10-28 22:39:23
【问题描述】:

我正在编写一个应用程序,该应用程序需要托管在已经使用现有应用程序的服务器上。 normal url 'www.site.org.au' 显示一个普通的网页, 然后还有两个子域 app.site.org.au 和 test.site.org.au,用于我们的应用程序和测试服务器。

我正在本地 xampp 服务器上开发此应用程序,但我希望能够在子域上开发此应用程序,以便在应用程序上线时,希望不会有太多的混乱和混乱。

为此,我有以下 https-vshost.conf

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/test"
    ServerName test.localhost.com
</VirtualHost>

同样我已经添加到我的主机文件中

127.0.0.1       test.localhost.com

可以看出,我已经在 htdoc 文件夹中设置了目录,这样当我访问 test.localhost.com 时,我会在 htdocs 中的 test 文件夹中加载页面。

我有如下的 .htaccess 文件

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    Options +Indexes
    RewriteEngine On

    RewriteBase /

    RewriteCond %{HTTP_HOST} !www.example.com$ [NC]
    RewriteCond %{REQUEST_URI} ^/$
    RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-_]+).example.com [NC]
    RewriteRule (.*) /index.php/controller/function/%2 [P]

    RewriteCond $1 !^(index\.php|images|robots\.text|css|js);
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

当前访问 test.localhost.com 给我一个 500 内部服务器错误

子域仅适用于单个应用程序,并且还需要能够使用其中的任何控制器。

那么,我在这里做错了什么?

编辑: 错误日志显示每个请求的以下行

[Tue Oct 29 08:55:10.044889 2013] [core:error] [pid 5884:tid 1652] [client 127.0.0.1:52811] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Tue Oct 29 08:55:10.044889 2013] [core:error] [pid 5884:tid 1652] [client 127.0.0.1:52811] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

【问题讨论】:

  • 你的错误日志是怎么说的?
  • 进行编辑以显示错误日志

标签: php apache .htaccess codeigniter mod-rewrite


【解决方案1】:

您的错误是您的第二条规则条件中有一个流浪;

RewriteCond $1 !^(index\.php|images|robots\.text|css|js);
# this is the culprit screwing everything up------------^

摆脱它,因为有了它,如果您在index.php 之后没有;,那么该条件将成立,而您没有。因此它会永远重写为/index.php/index.php

【讨论】:

  • 太好了,解决了这个问题,非常感谢,现在看来它正在破坏 url。当我尝试访问 test.site.com 时,它会重定向到 test.site.com/test.site.com/test.site.com/
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-08-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-01
  • 1970-01-01
相关资源
最近更新 更多