Welcome Guest, Not a member yet? Register   Sign In
mod_rewrite for multiple applications
#1

[eluser]obay[/eluser]
CI says to put the following code in .htaccess to remove "index.php" from the URL

Code:
RewriteEngine On
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

However, I have two applications sharing one CI installation. I renamed their index.php's to
Code:
admin.php
and
Code:
public.php

How do I modify the rewrite code for .htaccess? I've googled and searched the forums but none seems similar to my situation. Any help appreciated Smile

EDIT:
I access my pages like "OLD" below, when I want it to be like "NEW" below:

Quote:OLD: http://localhost/mysite/admin.php/story/edit/25
NEW: http://localhost/mysite/admin/story/edit/25

and
Quote:OLD: http://localhost/mysite/public.php/news/story/25/title-of-article
NEW: http://localhost/mysite/public/news/stor...of-article
#2

[eluser]@robertotra[/eluser]
It depends on how do you differentiate the HTTP requests to the different applications

Scenario: if you do by using the first segment of the url, then you can keep on redirecting everything to a index.php (your own index page, not CI's) and inside it you might check the first segment of the URI and then include the relative CI's (app)index file:

Quote:[EDIT] My proposed solution added unnecessary php code, better to use url_rewriting as explained in following posts. Snipped my code to improve the whole thread readability[/EDIT]

Bye
Roberto
#3

[eluser]obay[/eluser]
This is how I access the site:

Code:
Admin  -> http//yoursite.ext/admin.php[/controller[/method[/parameters]]]
Public -> http//yoursite.ext/public.php[/controller[/method[/parameters]]]

I tried your suggestion, it didn't work Sad
#4

[eluser]vbsaltydog[/eluser]
Just use one application with an admin controller and lock down access to the admin controller methods.
#5

[eluser]obay[/eluser]
vbsaltydog: not sure I know what you mean. Could you expound please?
#6

[eluser]vbsaltydog[/eluser]
Put all of your admin functions in an admin controller and force a login to an admin account for access to any method of the admin controller.
#7

[eluser]CroNiX[/eluser]
I agree with salty.

Just create an extra directory in your controllers directory and call it "admin" (or something not so guessable). Then put all admin controllers in there. You can only go 1 extra directory deep within /application.

/application/admin/controller1.php

Then when you create anchors and things, its just an extra segment in front: anchor('admin/controller1/method1', 'Click Me');

You can create a MY_Controller for admin and have all of your admin controllers extend that instead of CI_Controller. In MY_Controller, you would handle your auth so it protects all controllers that extend it in the /application/admin directory
#8

[eluser]obay[/eluser]
Okay, now I understand what vbsaltydog was trying to say. That might be a lot of work since my application is already up and running. I'll try to find other ways, and if I don't, I just might go with that suggestion, thanks! Others got any more ideas? Tongue
#9

[eluser]CroNiX[/eluser]
Either that or don't rewrite the admin.php and just include it in admin urls. Who cares if its seo friendly, its not going to be in google unless you have links to it, and only admin will see them.

Personally, I just put all admin controllers in their own directory. Same with the admin views and anything else only used by admin for code separation. Then you're not limited to a single "admin" controller, which can get huge depending on the complexity of your application.
#10

[eluser]obay[/eluser]
Oh yeah, you're right about that one!.. Hmmm.. Smile Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB