Question

I have a codeigniter php application which worked perfectly on my local machine(IIS) but when I deployed it on to a LAMP server (Apache), I can only access http://<ip-ddress>:8080/company/ but not any other links on that site eg. http://<ip-ddress>:8080/company/help, http://<ip-ddress>:8080/company/aboutus etc.

Here is my virtualhost entry for Apache on the remote server:

<VirtualHost *:8080>
        ServerAdmin xxxxxxx@xxx.xxx.xxx
        DocumentRoot "/app/content/pages"
        DirectoryIndex index.php
        ServerName company.xxx.xxxx.xxx
        ServerAlias company.xxx.xxxx.xxx
       LogLevel debug
        ErrorLog "|/app/server/apache2/bin/rotatelogs logs/company.xxx.xxxx.xxx-error_log 50M"

        <Directory "/app/content/pages">
            Options Includes FollowSymLinks
            AllowOverride All Options FileInfo
            Order allow,deny
            Allow from all

      <IfModule mod_php5.c>
            AddType application/x-httpd-php .php

            php_flag magic_quotes_gpc Off
            php_flag track_vars On
            php_flag register_globals Off
            php_value include_path .
          </IFModule>
    </Directory>

        #
        # The following lines prevent .htaccess and .htpasswd files from being
        # viewed by Web clients.
        #
        <FilesMatch "^\.ht">
            Order allow,deny
            Deny from all
            Satisfy All
        </FilesMatch>

        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml

        ServerSignature Off
</VirtualHost>

Here is my codeigniter config setting - application/config/config.php

$config['base_url'] = 'http://<ip-address>:8080/company/';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';
$config['proxy_ips'] = '';

Here is my application/config/routes.php:

$route['(:num)'] = "home/index/$1";
$route['help'] = "home/help";
$route['home/(:num)'] = "home/index/$1";
$route['default_controller'] = "home";
$route['404_override'] = '';
Was it helpful?

Solution

Adding rewrite rule helped like stormdain suggested in the comments but what was more specifically helpful was adding a rewritebase. here is what i came up with which worked

    <Directory "/app/content/pages/company">
        Options Includes FollowSymLinks
        AllowOverride All Options FileInfo
        Order allow,deny
        Allow from all

  <IfModule mod_php5.c>
        AddType application/x-httpd-php .php

        php_flag magic_quotes_gpc Off
        php_flag track_vars On
        php_flag register_globals Off
        php_value include_path .
  </IFModule>

   <IfModule mod_rewrite.c>
         RewriteEngine On
         # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
         #  slashes.
         # If your page resides at
         #  http://www.example.com/mypage/test1
         # then use
         # RewriteBase /mypage/test1/
        RewriteBase /company              ## earlier this had just a trailing slash
        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.

        ErrorDocument 404 /index.php
  </IfModule>             

</Directory>

    #
    # The following lines prevent .htaccess and .htpasswd files from being
    # viewed by Web clients.
    #
    <FilesMatch "^\.ht">
        Order allow,deny
        Deny from all
        Satisfy All
    </FilesMatch>

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml

    ServerSignature Off

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top