Codeigniter .htaccess not working in subdirectory
Posted
by
xzdead
on Stack Overflow
See other posts from Stack Overflow
or by xzdead
Published on 2013-10-19T18:04:57Z
Indexed on
2013/10/20
9:54 UTC
Read the original article
Hit count: 203
I have this codeingniter project structure
webRoot
|
|/application
| |
| |/controllers
| |
| |/admin
|
|/public
| |
| |/admin
| | |
| | |/css
| | |/img
| |/css
| |/img
And this is my .htacess file, located in /public. I use this in every local project running xampp:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
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.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
It works fine in localhost, but doesn't work in a dreamhost server. I always get "no input file specified". So after searching the web and trying lots of combinations, the best I got is this .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
With this one, if I go to
- http://development.mydomain.com - I see the codeigniter welcome page
But if I go to:
- http://development.mydomain.com/admin - I see the directory listing of /public/admin and doesn't execute the controller in /application/controllers/admin
Again, if I go to:
- http://development.mydomain.com/admin/admin - I see the private area, it executes the controller and goes to the default controller defined in routes, "dashboard"
This works fine too:
I have set in my config file:
$config['index_page'] = '';
$config['base_url'] = '';
$config['uri_protocol'] = 'AUTO';
I think that whatever is wrong in my .htaccess is causing other path issues I have with my project.
Any help would be great. Thanks to all in advance
EDIT: I removed this line:
RewriteCond %{REQUEST_FILENAME} !-d
because admin directory exists, that's why I see the public directory listing. But now I see the codeigniter welcome page when I go to http://development.mydomain.com/admin
So now my .htaccess file looks like:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
#RewriteRule ^(.*)$ /index.php?/$1 [L]
I also tried with the commented RewriteRule but I get the same result.
© Stack Overflow or respective owner