CodeIgniter app route/controller fails

NethServer Version: 6.10
Module: primary web server

I’m installing a web app into the primary server (ie, /var/www/html) and have hit a snag. Every other app I’ve installed has been fine, short of solving a few permissions problems.

This current app installs fine - that is, the provided installer works. The upgrade tool works. And the help system works. However, those tools are not written with CodeIgniter. As soon as I try to access the main system, the app using the CI route/controller system to direct traffic. For example:

https://my.server/sim/

Is the main page. As I’m not logged in, I’m routed to:

https://my.server/sim/auth/login

This all works perfectly on my test system installed into my HostGator account. However, on NS I get the following:

Not Found
The requested URL /sim/auth/login was not found on this server.

There is, of course, not actually a /sim/auth/login path. The .htaccess is supposed to reroute this. Here’s .htaccess:

DirectoryIndex index.php index.html
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /sim/
    RewriteCond $1 !^(index\.php|assets|install|update)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]
</IfModule>

Any ideas why this won’t work with NS? The app author - probably rightfully, as there are no problems under HostGator - calls this a server configuration problem and offers no help.

Seems like .htaccess files are not allowed by default.

Create /etc/httpd/conf.d/codeigniter.conf with following content to allow the override, in my test I installed CodeIgniter to /var/www/html/ci:

<Directory /var/www/html/ci>
   AllowOverride All
</Directory>

Now the .htaccess file in /var/www/html/ci should be used and the routing should work.

According to Apache docs you may write the whole .htaccess to /etc/httpd/conf.d/codeigniter.conf so no .htaccess file is needed at all.

<Directory /var/www/html/ci>
    DirectoryIndex index.php index.html
    RewriteEngine On
    RewriteBase /ci/
    RewriteCond $1 !^(index\.php|assets|install|update)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]
</Directory>

Don’t forget to restart apache after the config changes:

service httpd restart

Thanks!

I have noted all of that for future use.

For now, however, as I was under a time crunch, it occurred to me that I could create a shared folder (which do allow .htaccess files) and map it to the web root. So in the end, I have a shared folder “primary” mapped to the web root and won’t be using /var/www/html at all.

I’m thinking this will be my last NS6 system. Now that I’ve cleared this most recent hurdle, before I get any new requests from this location I plan to have them upgraded off NS6.

Thanks again!

1 Like