首页 文章

codeigniter在本地但在Web服务器上工作正常 . 404错误

提问于
浏览
6

Codeigniter在本地服务器上运行正常,但在Web服务器上运行不正常 .

我使用 XAMPP 进行本地开发 .

我正在使用Parallels Plesk Panel 11.0.9 for Microsoft Windows .

404 error page of codeigniter is not loading. Url is loadind 404 error page of the server. I have removed all .htacces rewrite rules of root directory and included index.php . Still it isn't working.

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

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和 its giving 404 error page of web server not of codeigniter

我在哪里错了?

2 回答

  • 11

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

    除了这个IIS没有读取 .htaccess 文件,而是我创建一个文件 web.config 并在mysite / httpdocs / demo / test / site /中用 .htaccess 替换

    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>
    

    现在网站已经启动并运行 . Thanks for the support .

  • 0

    我还不能评论,所以我会去回答 .

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

    EDIT 1

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

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

相关问题