Main domain with codeigniter, subdomain without codeigniter

I have uploaded a CodeIgniter site to public_html folder on server, which works properly.

http://my-site-name-here.com

Now, I have created a subdomain "sub" for which there is a directory in public_html named "sub". I have uploaded a non-CodeIgniter application in that folder. If I try to go to http://sub.my-site-name-here.com, it gives me "500 Internal server error". And if I try to go to http://my-site-name-here.com/sub, it gives me CodeIgniter response for page not found.

How can I set subdomain that does not use CodeIgniter?

UPDATE:

I am trying different htaccess rewrites. Current .htaccess content is:

RewriteEngine on
RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|img/current|css/current|js/current|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{HTTP_HOST} ^(www\.)?spiders\.haitspirit\.com$
RewriteCond %{REQUEST_URI} !^/spiders
RewriteRule ^(.*)$ /spiders/$1 [L]

UPDATE 2:

I have also moved all CodeIgniter directories and files (except index.php) into a directory called "main" and edited index.php accordingly. Still main site works, subdomain doesnt.

UPDATE 3:

I tried same thing in localhost and now able to get server error logs. Error shows it has reached maximum redirect loops.

Answers


I got the solution. Pasting here. It may help others who are using CodeIgniter package as main domain and non-CodeIgniter package as sub-domain and having trouble redirecting.

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^/sub/ [NC]
RewriteRule ^(.*)$ /index.php/errors/page_missing [L]

RewriteCond %{HTTP_HOST} ^sub\.sitename\.com$
RewriteCond $1 !^sub/
RewriteRule ^(.*)$ /sub/$1 [L]

RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|sub)
RewriteRule ^(.*)$ /index.php/$1 [L]

where sub is the name of sub-domain (assuming same name is used for directory too) and sitename is the name of your domain.

If anyone tries to go to http://sitename.com/sub then it will display 404 Not found page from CodeIgniter.

Hope this helps..


Need Your Help

How to import different header file depending some conditions

ios file header

There're two header files,for example a.h and b.h.

BuddyPress: Stop overriding default parameters passed to the template loop?

cookies android-activity buddypress

How do I stop BP from overriding default parameters passed to the template loop?