Hello,

I need help with htaccess and a sub domain.

I have a site I developed with ci 2.1.3

My folders structure is:
c:\sites\mysite
c:\sites\mysite\application
c:\sites\mysite\system
c:\sites\mysite\public_html\index.php
c:\sites\mysite\public_html\assets

In the public_html folder I have the htaccess file:

RewriteEngine On
RewriteCond $1 !^(index\.php|assets|images|robots\.txt|captcha)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 

Now I uploaded my site to the live server to a sub directory called: dev
I created a subdomain: dev.mysite.co.za

I uploaded all the files to the dev directory.

When I go to: dev.mysite.co.za

I get the page Index of with a list of the directories that are in the dev directory.

What do I need to do in order to see the site on the sub domain?

Can someone please help?

Dani AI

Generated

Quick diagnosis: an Apache “Index of” listing means the webserver did not find an index file inside the subdomain’s DocumentRoot. As pointed out, the subdomain’s DocumentRoot is the key detail; the symptoms shown by (a nested public_html inside the dev folder) strongly suggest the index.php used by CodeIgniter is not actually sitting where Apache expects it.

Practical fixes (in order): confirm the subdomain DocumentRoot in the hosting control panel. Either move the site’s public files so that the CodeIgniter index.php and assets are directly inside that DocumentRoot, or change the subdomain to point at the inner public folder. If the application and system directories are kept above the webroot, adjust index.php paths accordingly, for example:

$system_path       = '../system';
$application_folder = '../application';
$config['base_url'] = 'http://dev.mysite.co.za/';

.htaccess and Apache notes: force index.php as the directory index and stop directory listings by adding these to the subdomain root .htaccess (or vhost):

DirectoryIndex index.php index.html
Options -Indexes
# If using mod_rewrite from a subfolder, set a RewriteBase:
# RewriteBase /dev/

Troubleshooting checklist: place a simple index.php with phpinfo() in the subdomain root to verify DocumentRoot; check Apache error logs and file permissions; confirm mod_rewrite is enabled and AllowOverride All is allowed for that directory; ensure application/config/config.php has the correct base_url. Providing the actual subdomain DocumentRoot or the host’s subdomain configuration will make the exact fix obvious.

Recommended Answers

All 3 Replies

Update:

I moved the dev folder to the root folder so now I actually have a sub domain...

But now When I go to: dev.mysite.co.za I get this default web page with instructions:

If you are the web site owner, it is possible you have reached this page because:

The IP address has changed.
There has been a server misconfiguration.
The site may have been moved to a different server.

I wrote my host, and will post here if I find the answer.

Ok, sorry, as you can see I try lots of things....

The folder is now in the public_html folder.

Now if I go to:
dev.mysite.co.za I get 404 Page not found

if I go to mysite.co.za/dev I get the Index of page.

What I really want is to get my index.php page that sits in: public_html/dev/public_html.... lol cry lol

Hi,
so, the folder of the subdomain (dev) is inside the DocumentRoot of the main domain? Can you show the configuration?

The folder structure is something like below?

c:\sites\mysite
c:\sites\mysite\application
c:\sites\mysite\system
c:\sites\mysite\public_html\index.php
c:\sites\mysite\public_html\dev
c:\sites\mysite\public_html\dev\public_html\index.php
c:\sites\mysite\public_html\dev\application
c:\sites\mysite\public_html\dev\system
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.