I have a vendor folder created by composer on my codeigniter project and i also have a vendor controller, so when i load localhost/my_project/vendor
it will open the composer folder instead but when i use localhost/my_project/index.php/vendor
it loads the controller please any possible way of solving this issue. When i use localhost/my_project/admin
it works perfectly incase you thinking i didn't use the default .htaccess file.
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Vendor extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('paypal');
$this->load->library('twoCheckout_Lib');
$this->load->library('vouguepay');
/*cache control*/
$this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
$this->output->set_header('Pragma: no-cache');
//$this->crud_model->ip_data();
$vendor_system = $this->db->get_where('general_settings', array('type' => 'vendor_system'))->row()->value;
if ($vendor_system !== 'ok') {
redirect(base_url(), 'refresh');
}
}
/* index of the vendor. Default: Dashboard; On No Login Session: Back to login page. */
public function index()
{
if ($this->session->userdata('vendor_login') == 'yes') {
$page_data['page_name'] = "dashboard";
$this->load->view('back/index', $page_data);
} else {
$page_data['control'] = "vendor";
$this->load->view('back/login', $page_data);
}
}
You should to set right settings for your web server. You may setup rewrite rules as in example below. if you are using apache:
<LocationMatch "^/vendor">
RewriteRule . index.php [L]
</LocationMatch>
if you are using nginx:
location /vendor {
rewrite (.*) /index.php last;
}
Codeigniter uses the same Apache mod_rewrite snippet as so many applications:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Those both conditions first check if there is a file ( -f
) or directory ( -d
) with the requested name. And only if no such file or directory exists, the RewriteRule will take effect. Since you already have a directory "vendor" you have to set an exception for that directories name before the other rewrite:
RewriteCond %{REQUEST_FILENAME} ^vendor/.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
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.