簡體   English   中英

CodeIgniter在服務器上不起作用

[英]CodeIgniter doesn't work on Server

我嘗試了所有解決方案的變體,但仍然無法正常工作。

我在本地主機(MAMP)中開發了一些腳本

然后,我復制了文件和文件夾,但codeIgniter表示The page you requested was not found.

我怎么解決這個問題 ?

我試過了:-.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['base_url'] = 'http://oursite.com/review/';

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

仍然不起作用。

請幫助我。

親切的問候。

嘗試使用代碼而不是輸入來獲取baseurl:在config中添加以下行。

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

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

並且如果您的鏈接似乎不起作用,請嘗試以下其他方法之一:

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

“自動”默認-自動檢測

'PATH_INFO'使用PATH_INFO

“ QUERY_STRING”使用QUERY_STRING

'REQUEST_URI'使用REQUEST_URI

'ORIG_PATH_INFO'使用ORIG_PATH_INFO

您的設置是正確的,但是在您的.htaccess文件中,請用以下內容替換所有內容:

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

然后在其后編寫您自己的規則。

編輯

另外,我在項目中使用了大量CI,然后我的配置文件將通過以下步驟:

config.php文件

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

routes.php文件

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

具有以上.htaccess設置的所有服務器和本地計算機都可以使用。

並注意使您的CI在另一個目錄/子域中工作,然后再次檢查它。

.htaccess取決於服務器。 希望它將對您有所幫助:

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

您還可以按照以下討論:

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-Tricks-config-baseurl-in-109912.S.5948780645684621314?trk=groups_items_see_more-0-b-ttl

您可以嘗試以下方法:

<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['base_url'] = 'http://www.oursite.com/review/'; 路線: $route['default_controller'] = "realm";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM