Chris
Chris

Reputation: 764

.htaccess not working on codeigniter subdomain & directory install

I am trying to install CI under a directory which is also on a subdomain. So my base url would look like http://subdomain.domain.com/ci/

The following htaccess works fine on root of domain but not on directory, the browser says there is a redirect loop error.

Here is my code:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^sub\.domain\.com/ci/$
RewriteRule ^(.*)$ http://sub.domain.com/ci/$1 [L,R=301]

RewriteCond $1 !^(index\.php|assets)
RewriteRule ^(.*)$ /index.php?/$1 [L]

I am not very skilled with mod rewrite, any help would be appreciated! Thank you!

Upvotes: 0

Views: 2713

Answers (1)

Pete Mitchell
Pete Mitchell

Reputation: 2879

Inside your /ci directory your htaccess should be as follows

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f # this means if the requested file name doesnt exist 
RewriteCond %{REQUEST_FILENAME} !-d # this means if the requested directory doesnt exist 
RewriteRule ^(.*)$ index.php [L]

Based on your above comments that should be sufficient

Upvotes: 2

Related Questions