简体   繁体   English

CodeIgniter在服务器上不起作用

[英]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) 我在本地主机(MAMP)中开发了一些脚本

Then I copied the files and folders but codeIgniter says that The page you requested was not found. 然后,我复制了文件和文件夹,但codeIgniter表示The page you requested was not found.

How can I solve this problem ? 我怎么解决这个问题 ?

I tried : - .htaccess modification: 我试过了:-.htaccess修改:

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. 尝试使用代码而不是输入来获取baseurl:在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 'PATH_INFO'使用PATH_INFO

'QUERY_STRING' Uses the QUERY_STRING “ QUERY_STRING”使用QUERY_STRING

'REQUEST_URI' Uses the REQUEST_URI 'REQUEST_URI'使用REQUEST_URI

'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO 'ORIG_PATH_INFO'使用ORIG_PATH_INFO

Your setting is right , but in your .htaccess file , please replace everything by these : 您的设置是正确的,但是在您的.htaccess文件中,请用以下内容替换所有内容:

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 : 另外,我在项目中使用了大量CI,然后我的配置文件将通过以下步骤:

config.php config.php文件

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

routes.php routes.php文件

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

it will work in all servers and locals with above .htaccess settings. 具有以上.htaccess设置的所有服务器和本地计算机都可以使用。

And notice that make your CI work in another dir/subdomain then check it again. 并注意使您的CI在另一个目录/子域中工作,然后再次检查它。

.htaccess vary depending on server. .htaccess取决于服务器。 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 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 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> <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /review/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] </IfModule><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/'; config: $config['base_url'] = 'http://www.oursite.com/review/'; : $config['base_url'] = 'http://www.oursite.com/review/'; routes: $route['default_controller'] = "realm"; 路线: $route['default_controller'] = "realm";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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