简体   繁体   中英

URL-rewriting Codeigniter htaccess

Since I changed a website to another server, I have a problem that I can't access the website on domain.com/codeigniter/ . My default controller is info/ It worked with http://www.domain.com/codeigniter/info/ and http://www.domain.com/codeigniter/info/model/

$route['default_controller'] = "info/";
$route['404_override'] = '';
$route['info/(:any)'] = "info/view/$1";

.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

But on the new server it doesn't work. The problem is that it always ends in http://www.domain.com/index.php and not the index.php of the directory of the codeigniter installation..

What could be the problem?

there are a few things that make CodeIgniter work in secondary folder: first of all, you must change $config['base_url'] = http://www.domain.com/codeigniter/'; in application/config/config.php .

Then, of course, change .htacces file to this:

 <IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  # block hidden directories
  RewriteRule "(^|/)\." - [F]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
</IfModule>

Php mod_rewrite module is needed.

After changing the .htacces and leaving the 'base_url' empty ( http://www.domain.com/codeigniter/ doesn't work).

I have the following problems:

http://www.domain.com/codeigniter/ --> ERROR 404 from CI
http://www.domain.com/codeigniter/info/ --> No input file specified
http://www.domain.com/codeigniter/index.php/info/ --> OK

EDIT: Problem solved.. I forgot a ? after the index.php in the .htaccess & I changed the default controller in routes.php to info/view/home/

It was a combination of multiple things... It is strange that it worked on the old hosting. It was obviously wrong..

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