简体   繁体   中英

CodeIgniter doesn't work on Server

I tried all variations of solution but still doesn't work.

I developed some script in my localhost(MAMP)

Then I copied the files and folders but codeIgniter says that The page you requested was not found.

How can I solve this problem ?

I tried : - .htaccess modification:

RewriteEngine On
RewriteBase /review/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

config modification:

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

$config['uri_protocol'] = 'REQUEST_URI';

Still doesn't work.

Please help me about this.

Kind Regards.

Try to get baseurl using code instead of typing in: Add these lines in config.

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

$config['base_url']    = "$root";

and also If your links do not seem to work, try one of the others:

$config['uri_protocol'] = 'AUTO'; // This works for most servers.

'AUTO' Default - auto detects

'PATH_INFO' Uses the PATH_INFO

'QUERY_STRING' Uses the QUERY_STRING

'REQUEST_URI' Uses the REQUEST_URI

'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO

Your setting is right , but in your .htaccess file , please replace everything by these :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]  

Then write your own rules after it.

Edit

Also , i've used CI alot in my projects , then my config files go through this :

config.php

$config['base_url'] = ''; $config['index_page'] = '';

routes.php

$route['default_controller'] = "main";

it will work in all servers and locals with above .htaccess settings.

And notice that make your CI work in another dir/subdomain then check it again.

.htaccess vary depending on server. Hope it will help you:

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

You can also follow the following discussions:

https://www.linkedin.com/groups/Simple-Ticks-remove-indexphp-from-109912.S.5948862618142785540?trk=groups_items_see_more-0-b-ttl

And

https://www.linkedin.com/groups/Simple-Tricks-config-baseurl-in-109912.S.5948780645684621314?trk=groups_items_see_more-0-b-ttl

You can try this:

Htaccess: <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /review/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule>

config: $config['base_url'] = 'http://www.oursite.com/review/'; routes: $route['default_controller'] = "realm";

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