Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
487 views
in Technique[技术] by (71.8m points)

codeigniter working fine on local but not on web server. 404 Error

Codeigniter is working fine on local server but not on web server.

I used XAMPP for the development on local.

I am using 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.

Searched alot but couldn't find right solution

Directory for codeigniter folders(site, application, system)

is

mysite/httpdocs/demo/test/

Base url in mysite/httpdocs/demo/test/application/config/config.php

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

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

Deny from all

Envoirment set in 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';

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

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

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

I am giving url mysite/demo/test/site and its giving 404 error page of web server not of codeigniter

Where am I wrong here?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I contacted my host. They said that there was a problem in php handler.

Apart from this IIS doesn't read .htaccess file, Instead I make a file web.config and replace with .htaccess in mysite/httpdocs/demo/test/site/

Content of web.config file is

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

Now the website is up and running. Thanks for the support.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...