CodeIgniter Forums
Codeigniter installation in subdirectory - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Codeigniter installation in subdirectory (/showthread.php?tid=84705)



Codeigniter installation in subdirectory - AkinBredailik - 11-02-2022

I want to install the latest version of codeigniter in a subdirectory. That works so far. But now I want to remove the index.php from the url. So therefore I have this .htaccess file in the subfolder.

RewriteEngine On
RewriteBase /dev/

# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

###

# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]

# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
The name of the subfolder is dev and the webroot (the parent folder) is empty. There is just an index.html file in it.

So this is resulting in this structure:

/var/www/
    index.html
    dev/
        ci installation here
        .htaccess
and of course mod-rewrite is enabled.

Any ideas why it wont work? I get an 404 Error when calling something like


RE: Codeigniter installation in subdirectory - InsiteFX - 11-03-2022

You need to set the path in app/Config/Paths.php

Please note if you change the path spark will nolong work unless you change the path in spark also.


RE: Codeigniter installation in subdirectory - captain-sensible - 11-03-2022

your on Linux I think

,so another approach which i use for sub directory inside main web root of web server directory is via virtualhosts.

In that case you don't have to mess with .htaccess

use of virtualhost config also allows for easy production of access_log and error_log from CI4 in sub directory.

Basically then for live is a similar approach