【问题标题】:"No input file specified." in Two-Application Codeigniter“没有指定输入文件。”在两个应用程序 Codeigniter
【发布时间】:2014-05-20 10:50:36
【问题描述】:

我进行了广泛的搜索,但找不到解决问题的方法。

我将 codeigniter 与两个应用程序一起使用 - 一个用于前端,一个用于后端。

我的文件夹树是这样的:

  • 申请
    • 后端
    • 前端
  • 系统
  • index.php
  • admin.php

我已将 htaccess 文件写为:

RewriteEngine on

RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css)

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

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

我想从 URL 中删除“index.php”,但“admin.php”可以保留,没问题。它适用于前端,但是当我访问 /admin.php/login 时,它返回“未指定输入文件”。

在 Godaddy 托管中,我对这个 htaccess 没有任何问题,但现在我必须使用另一家托管公司。

你能帮帮我吗?非常感谢

【问题讨论】:

  • 您确定新主机使用的是 apache 并且正在处理 htaccess 文件吗?
  • 是的。在前端,没有问题。
  • 使用 index.php?/$1 您将 uri 作为 index.php 上的 QUERY_STRING 传递。 admin.php 既没有 PATH_INFO 也没有 QUERY_STRING。尝试在 htaccess 中为 admin.php 制定类似的规则
  • 你能帮我进一步吗兄弟?我无法想象htaccess的结构

标签: php .htaccess codeigniter


【解决方案1】:

我发现最适合我的方法是复制应用程序文件夹和 index.php 文件并在名为 backend 的目录中创建一个新文件夹。您可能需要做一些调整。

应用程序文件夹 索引.php “后端”文件夹 “后端/应用程序 "后端/index.php

同时添加到两个配置基 url "BASE" $config['base_url'] = BASE_URL;

我把主index.php也复制粘贴到后端index.php中

/*
 *--------------------------------------------------------------------------
 * Base URL
 *--------------------------------------------------------------------------
 *
 * Attemtps to figure the root web address
 *
 */
if (isset($_SERVER['HTTP_HOST']))
{
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST'];
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}   
else
{
$base_url = 'http://localhost/';
}

define('BASE_URL', $base_url);

unset($base_url);

【讨论】:

  • 感谢您的回答。但正如我所说,它在 Godaddy 托管中运行良好。所以我认为我的应用程序结构没有错。我想我只需要一个 htaccess 修复。
  • 如果您认为它是您的 htaccess,我已经添加了另一个答案,其中包含我用于 htaccess 的两个文件
【解决方案2】:

试试这个htaccess并访问这个页面http://philsturgeon.co.uk/blog/2009/06/How-to-Multi-site-CodeIgniter-Set-uphttp://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter

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

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

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

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

【讨论】:

    猜你喜欢
    • 2011-09-01
    • 1970-01-01
    • 2017-08-12
    • 1970-01-01
    • 1970-01-01
    • 2018-02-18
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多