[英]codeigniter page not found 404
我正在使用其他人使用 codeIgniter 創建的網站上工作,當我將其上傳到本地服務器時,它說找不到對象,因此我添加了 .htacess 文件以從鏈接中刪除 index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我遇到了另一個問題,即未找到頁面顯示 404 頁面(與之前的問題不同)和我的配置文件 base_url :
$root = "https://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
索引頁: $config['index_page'] = '';
uri 協議: $config['uri_protocol'] = 'REQUEST_URI';
當我在鏈接中添加“index.php”時它就起作用了。
在 .htaccess 和 config 中試試這個
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
$config['base_url'] = '';
$config['index_page'] = '';
or
$config['base_url'] = 'put-here-your-local-ip';
$config['index_page'] = '';
如果您使用 Xampp 檢查您的 htaccess 文件中的項目文件夾,您必須將 RewriteBase 設置為您的文件夾名稱
RewriteBase /YOUR_PROJECT/
檢查 application/config/config.php 中的配置文件
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME'])).'/';
檢查 application/config/route.php 中的路由文件
$route['default_controller'] = 'YOUR_Control_NAME';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.