Welcome Guest, Not a member yet? Register   Sign In
system and application folders above the web root
#1

Hi

To make a long story short. My folders structure is as follows :
Quote:project
application
system
public
index.php
My .htaccess :
Code:
RewriteEngine On
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
but locally, after url taped :
Quote:localhost/project
routers method _set_request() receives as argument an array :
Quote:segments ( [0] => project )
and makes directly "project" controller's name.

What am I missing ? Is it a configuration issue or something else ?

Thx in advance for any response.
Reply
#2

Finally within _parse_request_uri() of CI_URI class, I modified :
PHP Code:
if (isset($_SERVER['SCRIPT_NAME'][0]))
{
    if (
strpos($uri$_SERVER['SCRIPT_NAME']) === 0)
    {
        
$uri = (string) substr($uristrlen($_SERVER['SCRIPT_NAME']));
    }
    elseif (
strpos($uridirname($_SERVER['SCRIPT_NAME'])) === 0)
    {
        
$uri = (string) substr($uristrlen(dirname($_SERVER['SCRIPT_NAME'])));
    }

into:
PHP Code:
$script_name = (string) str_replace($this->config->item('public_folder_name'), ''$_SERVER['SCRIPT_NAME']);
       
if (isset(
$_SERVER['SCRIPT_NAME'][0]))
{
    if (
strpos($uri$script_name) === 0)
    {
        
$uri = (string) substr($uristrlen($script_name));                
    }
    elseif (
strpos($uridirname($script_name)) === 0)
    {
        
$uri = (string) substr($uristrlen(dirname($script_name)));  
    }

and it works even with hmvc installed.
Reply
#3

Anyone with significant CI experience have a better solution than the one presented above? I'm asking because I am having the exact same problem as OP, and I've looked all over the Internet for a solution to no avail.

I've tried many different combinations and configurations of .htaccess, Apache vhosts, and mod_rewrite, but nothing works. CI keeps thinking that the subdirectory that my code resides in is part of the default controller name.

I'd like to not have to modify CI core files in order to get this to work, but I will if I struggle with this for too much longer.

Thanks all
Reply
#4

You don't have to modify core classes, and really shouldn't. You extend them and can override methods or add new ones.
http://www.codeigniter.com/user_guide/ge...core-class
Reply
#5

Try adding a RewriteBase /project to your htaccess file.
Reply
#6

I create my app as below:

1. Folder structure:
-----------------------------

Code:
application
system
public
 + index.php
 + .htaccess
 + (other resources)
(other files)


All the files in the public folder are available to all users through http.
Note: the index.php was moved to public folder.

2. Modify the index.php:
-----------------------------

PHP Code:
$system_path '../system';
$application_folder '../application'


3. Content of .htaccess:
-----------------------------

Code:
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]


And that works for me.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB