简体   繁体   中英

Codeigniter on xampp error: The requested URL was not found on this server

I have a CodeIgniter web application that is running fine on my Host linux account, I'm trying to create a test environment in Windows and xampp, so I copied my files to a folder under xampp\\htdocs and removed .htaccessfrom the root app folder,my problem is the routes are not working, for example app/admin/login/signin works fine on host account but gives me 'The requested URL was not found on this server' on xampp.

my base_url code:

$ask_root = "http://".$_SERVER['HTTP_HOST'];
$ask_root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $ask_root; 

My application/.htaccess file:

DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|fonts|images|css|less|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [PT,L]
SetEnv TZ Asia/Jerusalem

What is the problem here?

Not sure this will help, but your base_url setup could be cleaner. Just do this

$config['base_url'] = "http://".$_SERVER['HTTP_HOST'].DIRECTORY_SEPARATOR;

For what it's worth, this .htaccess works for me

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

The setEnv line your .htaccess should not contribute to your problem.

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