简体   繁体   中英

Multiple apps Codeigniter: remove “index.php/controller” from URL

I am new to CodeIgniter and trying to understand the basics and maybe some advance methods to set an MVC based application. After a while I thought i might get a try to set a admin panel as well and created and second folder as admin application.

This is my folder structure:

www.domain.com
    --frontend
    --admin

In each folder is an app set with it's own .htaccess file. Bellow is the .htaccess file for admin side.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /admin/
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]    
</IfModule>

Current working url is www.domain.com/admin/index.php/admin/posts and I am trying pointless to change it to w ww.domain.com/admin/posts . So how do I remove the /index.php/admin from url.

The $config['base_url'] is set accordingly for each side(admin/frontend) and the default index.php is set null also , $config['index_page'] = '';

Is this the problem cause I have 2 different apps or just a bad configuration? What is the best practice with multiple applications same site?

Hope i did not duplicated any post and if so please don't hate and try to help me. I am deeply grateful to all of you.

Try this

in config.php

$config['base_url'] = '';
$config['index_page'] = '';

in .htacess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

EDIT 01

<link href="<?php echo base_url(); ?>css/style.css" rel="stylesheet" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM