Welcome Guest, Not a member yet? Register   Sign In
Codeigniter installation in subdirectory
#1

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
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

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
CMS CI4     I use Arch Linux by the way 

Reply




Theme © iAndrew 2016 - Forum software by © MyBB