1

I have a site created using CodeIgniter, and the application is installed on the web root (/). This is a shared hosting environment on GoDaddy. For creating a Development environment, I copied the same and created a /development folder in the / root.

Now, my main site works well, but when I try to use any link on the sub-directory (linked to a different domain name), it is always giving me a 404 error.

I have tried the solution given on Stackoverflow, but it does not work.

Duplicate of: CodeIgniter won't run in a subdirectory

So my structure is:

/system
/application1
/index.php
/.htaccess
/development/application2
/development/index.php
/development/.htaccess

The top level .htaccess contains:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ index.php/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

The sub-directory .htaccess is:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /development/

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 index.php
</IfModule> 

(I have even tried the suggestions given on StackOverflow to add a ./ in front of the INDEX.PHP files, and the suggestions provided in the other ticket)

The $system_path in the sub-directory points to the top level /system folder, so as to avoid any conflicts.

The main page displays correctly on the site, & even the main page of the sub-domain, created as:

http://www.mysite.co/ 
http://development.mysite.co/

But any links from the sub-domain created show the 404 error and I have not been able to get any of the links working.

I am hosting on a shared server (Linux) on GoDaddy and have PHP 5.3 installed. The main root is at a location (absolute path): /home/content/22/88885555/html

And the sub-directory I have created is at (absolute path): /home/content/22/88885555/html/development

I have used the paths as:

/
/development/

Does anyone have knowledge of or has experimented with such a setup?

Community
  • 1
  • 1
gagneet
  • 35,729
  • 29
  • 78
  • 113

1 Answers1

1

Within /index.php modify the following lines:

$system_path = "/path/to/your/public_html/system";
$application_folder = "/path/to/your/public_html/application1";

Now edit /application1/config/config.php

Find the following lines and change to your domain name.

$config['base_url'] = 'http://mysite.co';
$config['index_page'] = ''; 

Open up /.htaccess and amend to the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

ReWriteCond %{HTTP_HOST} mysite.co
RewriteCond $1 !^(index\.php|development)
ReWriteRule ^(.*)$ /index.php/$1 [L]

ReWriteCond %{HTTP_HOST} development.mysite.co
ReWriteCond %{REQUEST_URI} !development/

ReWriteRule ^(.*)$ development/index.php/$1 [L]

Now for your sub directory application.

Open up /development/index.php

Amend the following lines to match your setup:

$system_path = "/path/to/your/public_html/system";
$application_folder = "/path/to/your/public_html/development/application2";

Notice the system_path is the same as application1?

Modify the config file of application2. Open up /development/application2/config/config.php and amend the base url to your test site.

$config['base_url'] = 'http://development.mysite.co';

Finally remove, /development/.htaccess.

verheesj
  • 1,438
  • 2
  • 16
  • 24
  • No, that still does not work! I have even tried using a different URL/domain for the sub-folder (i.e. http://www.mysite1.co), and the main site as a sub-domain (i.e. http://prod.mysite.co, which repoints to http://www.mysite.co), but no resolution. – gagneet Apr 21 '14 at 20:55