简体   繁体   中英

Codeigniter cannot access controller without index.php

My local xampp codeigniter projec's url was http://localhost/ci_yudeesh/index.php But then wanted to remove the index.php part from the url so I followed the steps given in the userguide.

After that i could access the project without index.php with the url http://localhost/ci_yudeesh/

I have a controller named Home and I can access this using http://localhost/ci_yudeesh/index.php/home , but when try to access this using http://localhost/ci_yudeesh/home it gives this error:

错误图片

this is my config:

$config['base_url'] = 'http://localhost/ci_yudeesh/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

this is my .htaccess:

<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>

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

this is my route:

$route['default_controller'] = 'Home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

Can someone help me fixing this? I tried all the other answers to similar type questions but none worked.

Remove the .htaccess from the application folder and put it outside the application folder and written only the below code in it. If it not work then I will give you another .htaccess code.

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

Change the .htaccess file . Remove the codes from the existing file and add the following codes on the file :-

RewriteEngine on

RewriteCond $1 !^(index.php|resources|robots.txt)

RewriteBase /ci_yudeesh/

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.

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