0

My project is not working in online (cpanel) "https://www.sample.com/folder"

But i give my url like this means working
"https://www.sample.com/folder/index.php/controller_name"

i want like "sample.com/folder/controller_name"

how to resolve this. I want my URL like above the first one

My Config file information

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

my Route file like this, Is here any Problem.

$route['default_controller'] = "pages/home";
$username = '(:any)';
$route['404_override'] = '';
$route['sample/([0-9]+)'] = "sample/index/$1";
$route['pages/profile'] = "pages/profile"; 
$route['pages/userList'] = "pages/userList";
$route['auth/logout'] = "auth/logout";
$route['auth'] = "auth/logout";
$route['auth/login'] = "auth/login";
$route['auth/register'] = "auth/register";
$route['pages/post'] = "pages/post";
shruthi
  • 119
  • 13

3 Answers3

0

first you change in your config.php

 $config['index_page'] = 'index.php'; 

To

$config['index_page'] = '';

change

$config['base_url'] = 'https://www.sample.com/';

and your HTACCESS file

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
Aslam Patel
  • 834
  • 6
  • 17
0

Change your .htaccess file at "https://www.sample.com/folder" to

RewriteEngine On
RewriteBase /folder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Jatin Raikwar
  • 377
  • 3
  • 16
0

in your config file you need to change

$config['index_page'] = 'index.php'; 

to

$config['index_page'] = '';

then change

$config['base_url'] = '';

to

$config['base_url'] = 'https://www.sample.com/folder/';
//you need to put the folder

then in your .htacces //put it in root path like /var/www/foler/

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /folder/index.php/$1 [L]
elddenmedio
  • 1,032
  • 1
  • 7
  • 15