skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. I cannot comment yet, so I’ll go for an answer.

    Check your project root directory if you have the .htaccess file and if you have access to the server, might as well check too if mod_rewrite is enabled (assuming you are using Apache). This might be an URL rewrite issue.

    EDIT 1

    Ok now I see you have a .htaccess file in there. How about the <Directory> directives in your httpd.conf or is this setup via <VirtualHost>?

    EDIT 2

    Try changing your .htaccess with this:

    <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>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search