Welcome Guest, Not a member yet? Register   Sign In
Frontend & backend .htaccess
#1

[eluser]Rein Van Oyen[/eluser]
Hi all,



I'm struggling with this for ages now.

I have two applications running on 1 CodeIgniter system. My files for incoming requests are named index.php and admin.php. I have been using them successfully (at the same time) using url's like http://www.mydomain.com/index.php/controller/method/ and http://www.mydomain.com/admin.php/controller/method/

So my applications are fully working.

Now I want to use .htaccess get the php-filenames out of the url. Deleting the index.php one was an easy task. I use the following for this;

Code:
RewriteEngine On
RewriteBase /

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

Now the hard part is this: I want to link http://www.mydomain.com/admin/ to my admin.php, so that it appears to be in a subfolder. so I made my .htaccess something like this;

Code:
RewriteEngine On
RewriteBase /

RewriteRule ^admin$ /admin.php/$1 [L]
RewriteRule ^admin/(.*)$ /admin.php/$1 [L]

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

When requesting http://www.mydomain.com/admin/ it returns a CodeIgniter error. However, it is the error of the admin.php application. So it loads the right application, but it is unable to load the right controller.

Is this an issue with my config.php for the admin.php application? Is there anyone who can point me in the right direction?


Thanks in advice,
Rein
#2

[eluser]InsiteFX[/eluser]
Time to look into using Modules like HMVC.

InsiteFX
#3

[eluser]vikascoollives[/eluser]
May this will work :


1. Open config.php from system/application/config directory and replace
$config['index_page'] = “admin.php” by $config['index_page'] = “admin”

2. Create a “.htaccess” file in the root of CodeIgniter directory (where the system directory resides), open the file using your favorite text editor, write down the following script and save it:

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

3. In some case the default setting for uri_protocol does not work properly. To solve this problem just replace
$config['uri_protocol'] = “AUTO” by $config['uri_protocol'] = “REQUEST_URI” from system/application/config/config.php
#4

[eluser]Rein Van Oyen[/eluser]
vikascoollives, the problem is I'm having two files like the admin.php file. One is index.php the other one is admin.php.

What I want is basically this;
www.mydomain.com/anycontroller/ -> www.mydomain.com/index.php/anycontroller/
and this:
www.mydomain.com/admin/anycontroller/ -> www.mydomain.com/admin.php/anycontroller/

Any ideas?
#5

[eluser]steelaz[/eluser]
You don't need 2 separate entry points (index.php and admin.php). If you place your admin controllers in /application/controllers/admin/ and use regular .htaccess setup, you can have

domain.com/anycontroller/
domain.com/admin/admincontroller/
#6

[eluser]ramm[/eluser]
[quote author="steelaz" date="1299612932"]You don't need 2 separate entry points (index.php and admin.php). If you place your admin controllers in /application/controllers/admin/ and use regular .htaccess setup, you can have

domain.com/anycontroller/
domain.com/admin/admincontroller/[/quote]

That's how i do it, works fine for me.




Theme © iAndrew 2016 - Forum software by © MyBB