简体   繁体   中英

Removing index,.php from codigniter on xamp not working

i have installed codigniter on xamp but I have searched on google and have tried many things but stil when I type in address it shows me object not found but when I add index.php it is working fine how do I remove index.php and make it work properly

Here is my .htaccess

RewriteEngine On
RewriteBase /mywebsite
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [PT,L]

This is my config.php

$config['base_url'] = '/mywebsite';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

This is my routes .php

$route['default_controller'] = "home";
$route['404_override'] = 'c404';
$route['post/(:any)/(:any)'] = "blog/viewPost/$2";
$route['category/(:any)/(:any)'] = "blog/viewPostcategory/$2/$1";
$route['search'] = "blog/search";
$route['symbol/(:any)'] = "companies/view/$1";

Your base url should be:

http://localhost/mywebsite/

And you shouldn't need this in your htaccess:

RewriteBase /mywebsite

1) Remove RewriteBase /mywebsite from .htaccess

2) Make sure mod_rewrite is enabled

3) Make sure your $config['base_url'] is correct

4) Your .htaccess file must be in root directory of your project and not of application directory

.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]

ensure .htaccess file is inside of mywebsite/

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

config.php

$config['base_url'] = 'http://localhost/mywebsite';

Then navigate to http://localhost/mywebsite

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