Routes not working when uploaded to server (CodeIgniter)

℡╲_俬逩灬. 提交于 2019-12-14 00:34:55

问题


I created a site on CodeIgniter and everything works fine on XAMPP. But when I upload my file to the server the routes stopped working. I'm getting 404 URL not found error on all the page except the index page.

here is my routes.

$route['default_controller'] = "onlinec";
$route['404_override'] = '';
$route['home'] = 'serial/home/';
$route['done'] = 'serial/done/';
$route['redeem'] = 'serial/redeem/';
$route['printpage'] = 'serial/printpage/';
$route['login'] = 'serial/auth/login';
$route['logout'] = 'serial/auth/logout';

here is my .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

on http:/***/serial/home I get a 404 URL not found error

on http:/***/serial/ I get the page properly.

so only the index.php work at the moment

tried all possibilities on $config['uri_protocol'] = 'AUTO'; and my mod_rewrite is on in httpd.conf

can anyone help me out. This is a AWS Linux server.


回答1:


Try to add in htaccess Rewritebase like :

RewriteEngine On

RewriteBase /

or

RewriteEngine On

RewriteBase /subfolder/subsubfolder/

and try to set

$config['base_url'] like:

$config['base_url'] = 'http://yourwebsite.com/';

instead of:

$config['base_url'] = '';

in your config file.



来源:https://stackoverflow.com/questions/17064451/routes-not-working-when-uploaded-to-server-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!