我已經與有類似問題的人一起閱讀了多個執行緒,但似乎沒有一個解決方案對我有用。我的網站托管在 http://localhost/mysite/。
我有一個 codeigniter 站點并且正在使用 XAMPP。
任何時候我想訪問一個頁面時,我的 URL 中有 index.php(http://localhost/mysite/index.php/newpage 或 http://localhost/mysite/index.php/anothernewpage)
這是我的 .htaccess 檔案
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
這是我的組態檔
$config['base_url'] = "http://localhost";
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
這是我的路線
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
我還在 httpd.conf 檔案 (XAMPP) 中取消注釋以下行
LoadModule rewrite_module modules/mod_rewrite.so
如果我嘗試在不包含 index.php (http://localhost/mysite/newpage) 的情況下訪問站點的某個區域,則會收到錯誤 404 在此服務器上找不到請求的 URL。我必須把完整的 url http://localhost/mysite/index.php/newpage。誰能幫我弄清楚這個設定有什么問題?
uj5u.com熱心網友回復:
您的基本網址應該是 $config['base_url'] = "http://localhost/mysite";
uj5u.com熱心網友回復:
在 .htaccess 的根目錄中(如果不存在,則創建一個):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
在 application/config/config.php
$config['base_url'] = ((isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) || $_SERVER['HTTPS']==1)) ? "https" : "http")."://".$_SERVER['HTTP_HOST']."/";
在本地主機(僅本地主機)中,在 $config['base_url'] 中的 '/' 后添加站點名稱;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/342481.html
上一篇:如何將其他groovy檔案匯入到我的pipeline.groovy檔案中?
下一篇:將資訊從AJAX傳遞到控制器類
