Welcome Guest, Not a member yet? Register   Sign In
Admin folder in subfolder not working...
#1

Hello guys,
Here's the thing.

I've created the main application in the subdomain sub.domain.com and i've placed another admin ci application in sub.domain.com/admin/.

The problem is that when i'm trying to access the subfolder what i get is a 404 error "not found" page.

Here's the .htaccess of the admin application:
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]    

<IfModule mod_rewrite.c>
RewriteEngine on
#
# stuff to let through (ignore)
RewriteCond %{REQUEST_URI} "/admin/"
RewriteRule (.*) $1 [L]
#
</IfModule>

The config.php base_urls: 
Code:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = 'https://sub.domain.com/admin/';

/*
|--------------------------------------------------------------------------
| Base site url
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['front_url'] = 'https://sub.domain.com/';



And here's the routes.php (note: I've placed the controllers in subfolders):
Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
* Users login - logout
*/
$route['login']  = 'users/users/login';
$route['logout'] = 'users/users/logout';

/**
* Projects
*/
$route['projects'] = 'projects/projects';
$route['projects/new']    = 'projects/projects/new';
$route['projects/edit/(:any)']     = 'projects/projects/edit/$1';
$route['projects/(:any)'] = 'projects/projects/$1';

/**
* Posts
*/
$route['posts']    = 'posts/posts';
$route['posts/new']= 'posts/posts/new';
$route['posts/edit/(:any)'] = 'posts/posts/edit/$1';
$route['posts/(:any)']     = 'posts/$1';


/**
* Customers
*/
$route['customers'] = 'customers/customers';
$route['customers/(:any)'] = 'customers/customers/$1';
$route['customers/edit/(:any)'] = 'customers/customers/edit/$1';

/**
* Admin users
*/
$route['users'] = 'users/users';
$route['users/(:any)'] = 'users/users/$1';

/**
* Orders
*/
$route['settings/(:any)'] = 'settings/$1';
$route['settings'] = 'settings';


/**
* Redirect any URI after default url
*/
$route['pages/(:any)'] = 'pages/$1';

/**
* Any URI pass
*/
$route['(:any)'] = 'pages';
$route['default_controller'] = 'pages';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

I've searched all over the net and i cant find anything useful.. Thanks...

//Life motto
if (sad() == true) {
     sad().stop();
     develop();
}
Reply
#2

@HarrysR,

Is the CI software in a subdirectory? What happens when you type in domain.com/subdirectory? Subdirectory being where the CI code is.
Reply
#3

As i mentioned above yes! It is located in subdirectory.. When i type the subdirectory URL i get a 404 not found page..

//Life motto
if (sad() == true) {
     sad().stop();
     develop();
}
Reply
#4

Did you try adding the RewriteBase to your .htaccess file?

Code:
RewriteEngine On
RewriteBase "sub.domain.com/admin/"
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(07-15-2019, 04:05 PM)InsiteFX Wrote: Did you try adding the RewriteBase to your .htaccess file?

Code:
RewriteEngine On
RewriteBase "sub.domain.com/admin/"

Yes, and i still get the 404 error page!

//Life motto
if (sad() == true) {
     sad().stop();
     develop();
}
Reply
#6

(This post was last modified: 07-16-2019, 09:11 AM by php_rocs.)

@HarrysR,

I think that your config file is wrong.

I think that....
$config['base_url'] = 'https://sub.domain.com/admin/';
should be:
$config['base_url'] = 'https://sub.domain.com';

My understanding of subdomains is that when calling the subdomain you use...
sub.domain.com and domain.com/admin not sub.domain.com/admin

I have a subdomain on one of my accounts and the url links listed above (minus the last one) are the ones I use and they work perfectly. When I type sub.domain.com/admin I get an 404 error message too.
Reply
#7

(This post was last modified: 07-16-2019, 10:26 AM by HarrysR.)

@php_rocs
If i do this i get redirected to the main website.

I forgot to mention that in my header i have this script, in order to prevent users that are not admins to enter the admin panel and if the user is not logged in to redirect him in homepage...

if (!$this->ion_auth->logged_in() && $this->uri->segment(1) !== 'login') {
redirect('login');
} elseif($this->ion_auth->logged_in() && !$this->ion_auth->is_admin($this->ion_auth->get_user_id())){
redirect('logout');
}

//Life motto
if (sad() == true) {
     sad().stop();
     develop();
}
Reply
#8

@HarrysR,

It looks like your missing a default condition. What if neither of the conditions are met where should the user be redirected.

You have

If condition
else if condition
and no default

instead of

If condition
else if condition
else condition (default)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB