CodeIgniter Forums
Front-end, Back-end and htaccess - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Front-end, Back-end and htaccess (/thread-10685.html)



Front-end, Back-end and htaccess - El Forum - 08-08-2008

[eluser]Sceneshift[/eluser]
I've done a fair amount of searching and I can't seem to find a solution to this problem.

I have the following file structure:

Code:
application
- admin
- site
system

And of course two php files (index.php and admin.php) both located in the root. The site is working fine, but I am trying to configure my htaccess file so that anything http://www.mysite.com/admin/ will read the admin.php file and ANYTHING ELSE will read the index.php file.

Can anyone help?


Front-end, Back-end and htaccess - El Forum - 08-08-2008

[eluser]Yash[/eluser]
Why with htaccess just simply use a controller name admin and load admin.php in index function of this controller.You're done.


Front-end, Back-end and htaccess - El Forum - 08-08-2008

[eluser]Sceneshift[/eluser]
I'm not sure the above would work since I'd like http://www.mysite.com/admin/ to act as the root for my 'backend' application.. for example:

http://www.mysite.com/admin/controller/method/

I understand I could have a route setup so anything /admin/ automatically points to admin.php's root controller, but I'd prefer to just rewrite it.


Front-end, Back-end and htaccess - El Forum - 08-08-2008

[eluser]gon[/eluser]
You can store controllers into subfolders (1 level deep only).

So you just have to create /controllers/admin/ and place your admin controllers there.


Front-end, Back-end and htaccess - El Forum - 08-08-2008

[eluser]Yash[/eluser]
you can use ../../ to load files using view in your case
Code:
$this->load->view('../../application/admin')



Front-end, Back-end and htaccess - El Forum - 08-08-2008

[eluser]missionsix[/eluser]
I think you need something like this:

.htaccess:
Code:
RewriteEngine On
RewriteRule ^admin/(.*)$ admin.php?$1 [nc,QSA]
RewriteCond $1 !^(index\.php|images|javascript|css|admin)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]



Front-end, Back-end and htaccess - El Forum - 08-08-2008

[eluser]Sceneshift[/eluser]
Thanks missionsix, top one!


Front-end, Back-end and htaccess - El Forum - 08-08-2008

[eluser]missionsix[/eluser]
Np, glad i could help.