Welcome Guest, Not a member yet? Register   Sign In
codeigniter in a subdirectory, some issues.
#1
Exclamation 

Hey all,

I am rebuilding a site for a client in codeigniter. Since their original site needs to stay active I am building the new site in a subdirectory. I feel like this may be the cause of my problems, so I'm wondering if there are any special steps I can take to get the site to run properly. My main symptoms are as follows:

for reference, sites url: http://sleepawake.com. I have placed codeigniter at: sleepawake.com/2013/application

1. home controller is loading properly and php is working because the different views are being displayed by the controller. However all of the files I am referencing throughout the page will only resolve if they look like this(for example):

http://sleepawake.com/2013/application/c.../reset.css

whereas typically I would expect this to work:

http://sleepawake.com/2013/common/styles/reset.css

Not sure why the structure is all wrong, but it may have to do with the second issue....


2. Only the home controller works, no other controllers are accessible. I simply get a 404 when trying to access. Feel like this may have something to do with phpindex / htaccess or some config.

My index.php is the main culprit. I normally expect to leave the file in the "application" folder. However, when I do that, I dont get my home controller, but instead the site will only load a page that says "index of /2013", and then lists all the files in the root as links:

Parent Directory
   .gitignore
   .travis.yml
   application/
   license.txt
   user_guide/

when I put the index.php file in the /2013/ folder, the home controller resolves, but I cant access any other controllers and the directory structure of all my files is off.

I feel like my index.php should be in the /2013/application/ folder, but there is another configuration issue that is causing the "index of..." page to display.

Might be confusing, not sure if I covered everything I needed to cover. Have been trying at this for 2 days to no avail, hoping that someone might be able to give me guidance. Any help would really be appreciated.

For reference I'll put my htaccess below. Have also tried all manner of htaccess and config settings, but nothing seems to work. In fact, I have found that my htaccess settings make little difference at all (if any), and that it is mainly the location of my index file that makes/breaks the site.

Code:
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /2013/
 RewriteCond %{REQUEST_URI} ^system.*
 RewriteRule ^(.*)$ 2013/index.php?/$1 [L]
 RewriteCond %{REQUEST_URI} ^application.*
 RewriteRule ^(.*)$ 2013/index.php?/$1 [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ 2013/index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
 ErrorDocument 404 ci/index.php
</IfModule>  

also tried things like:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

and at some points used some AddHandlers (some instances the browser would try to download 'application/x-httpd-php' when i ping the homepage.)

for config, I tried a number of different URI protocols and base_url settings.
Reply
#2

first .htaccess is fine.
i suppose it's about base url on your config,
plese check base url on config/config.php
$config['base_url'] = "http://localhost/something/";
www.arthnugraha.com
Learning by doing
Reply
#3

(12-04-2014, 08:32 AM)malokevi Wrote: http://sleepawake.com/2013/application/c.../reset.css

whereas typically I would expect this to work:

http://sleepawake.com/2013/common/styles/reset.css


(not 100% sure I know how those links are generated.. however)

Your htaccess file can be updated to exclude directories that are same level as application/
perhaps "common" is attempting to be run as a controller due to RewriteCond

So after you set your base directory to 2013 and set the codeigniter base properly
PHP Code:
RewriteCond $!^(index\.php|images|media|assets|common|themes|robots\.txt)
RewriteRule ^(.*)$ /index.php/$[L
Reply
#4

Why don't you move your "common" directory outside of "application" ? I think it make more sense to put JS, CSS and images at the root of the web site. And you won't have to mess with htaccess to make your links work.


Quote:My index.php is the main culprit. I normally expect to leave the file in the "application" folder. However, when I do that, I dont get my home controller, but instead the site will only load a page that says "index of /2013", and then lists all the files in the root as links:


Parent Directory
   .gitignore
   .travis.yml
   application/
   license.txt
   user_guide/

Why would you move index.php inside application? It is supposed to be outside application. Leave it there! That is exactly why nothing load and you only see a list of files...
Reply
#5

Hi malokevi,

>>> I am rebuilding a site for a client in codeigniter.
>>> Since their original site needs to stay active I am building the new site in a subdirectory.

As includebeer mentioned it is far easier to follow the recommended installation guidelines.

To prevent two conflicting live sites I find it far easier to create new sites in a subdomain (also to archive previous versions into subdomains).

Benefits:
1. only requires a single change to index.php application_folder.
2. the $system_path should be common to all installations and above root (easier to up/downgrade).
3. uses recommended .htaccess file.
4. application folder can be moved easily from subdomain to root and vice-versa.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB