6

Codeigniter 在本地服务器上运行良好,但在 Web 服务器上运行良好。

我用于XAMPP本地开发。

我正在使用适用于 Microsoft Windows 的 Parallels Plesk Panel 11.0.9。

未加载 codeigniter 的 404 错误页面。Url 是服务器的 loadind 404 错误页面。我已经删除 .htacces 了根目录的所有重写规则并包含 index.php. 仍然无法正常工作。

搜索了很多,但找不到正确的解决方案

codeigniter 文件夹的目录(站点、应用程序、系统)

mysite/httpdocs/demo/test/

mysite/httpdocs/demo/test/application/config/config.php中的基本 url

$config['base_url'] = 'http://mysite/httpdocs/demo/test/site/';

mysite/httpdocs/demo/test/application/.htaccess

Deny from all

在 index.php ( mysite/httpdocs/demo/test/site/index.php )中设置的环境

switch (dirname(__FILE__)) {
        case 'http://mysite/httpdocs/demo/test/site':
            define('ENVIRONMENT', 'development');
        break;

        default:
            define('ENVIRONMENT', 'production');
        break;
    }
          $system_path = '../system';
          $application_folder = '../application';

mysite/httpdocs/demo/test/site/.htaccess

               <IfModule mod_rewrite.c>
                           Options +FollowSymLinks
                           RewriteEngine on
                           RewriteCond %{REQUEST_FILENAME} !-f
                         RewriteCond %{REQUEST_FILENAME} !-d
                          RewriteRule ^(.*)$ index.php/$1 [L]
              </IfModule>

mysite/httpdocs/demo/test/application/config/routes.php

           $route['default_controller'] = "page";
           $route['404_override'] = 'page';
           $route['article/(:num)/(:any)'] = 'article/index/$1/$2';

我给出了 url mysite/demo/test/site及其 给出的 Web 服务器的 404 错误页面,而不是 codeigniter

我在这里错在哪里?

4

2 回答 2

12

我联系了我的主人。他们说php处理程序有问题。

除了这个 IIS 不读取.htaccess文件,而是创建一个文件web.config并替换为.htaccessmysite /httpdocs/demo/test/site/

文件内容web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<system.webServer>

    <httpErrors errorMode="Detailed" />
    <asp scriptErrorSentToBrowser="true"/>

    <rewrite>
    <rules>
        <rule name="RuleRemoveIndex" stopProcessing="true">
            <match url="^(.*)$" ignoreCase="false" />
            <conditions>
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
            </conditions>
            <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true"/>
        </rule>
    </rules>
    </rewrite>

</system.webServer>

<system.web>
    <customErrors mode="Off"/>
    <compilation debug="true"/>
</system.web>

</configuration>

现在该网站已启动并运行。感谢您的支持

于 2013-07-16T05:05:29.860 回答
0

我还不能发表评论,所以我会去寻求答案。

检查你的项目根目录,如果你有.htaccess文件,如果你可以访问服务器,也可以检查是否mod_rewrite启用(假设你使用的是 Apache)。这可能是 URL 重写问题。

编辑 1

好的,现在我看到你.htaccess那里有一个文件。你的httpd.conf<Directory>中的指令怎么样,或者这个设置是通过?<VirtualHost>

编辑 2

尝试.htaccess用这个改变你的:

<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>
于 2013-07-13T13:50:01.107 回答