我的项目无法在线工作(cpanel) “https://www.sample.com/folder”
但我给我的网址就像这意味着工作 “https://www.sample.com/folder/index.php/controller_name”
我想要“ sample.com/folder/controller_name ”
如何解决这个问题。我希望我的网址像上面的第一个
我的配置文件信息
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
我的路线文件是这样的,这里有任何问题。
$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";
答案 0 :(得分:0)
首先更改config.php
$config['index_page'] = 'index.php';
到
$config['index_page'] = '';
更改
$config['base_url'] = 'https://www.sample.com/';
和您的HTACCESS文件
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
答案 1 :(得分:0)
将您的.htaccess
文件更改为" https://www.sample.com/folder"到
RewriteEngine On
RewriteBase /folder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
答案 2 :(得分:0)
需要更改
$config['index_page'] = 'index.php';
到
$config['index_page'] = '';
然后改变
$config['base_url'] = '';
到
$config['base_url'] = 'https://www.sample.com/folder/';
//you need to put the folder
然后在你的.htacces //把它放在根路径中,如/ var / www / foler /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /folder/index.php/$1 [L]