簡體   English   中英

CodeIgniter:URL重寫不起作用

[英]CodeIgniter : URL rewriting not working

我有一個使用CodeIgniter創建的網站,盡管URL重寫在我的本地安裝(WAMP)上有效,但在我的遠程服務器上卻失敗。

CI框架安裝在“ / dev”文件夾中。

當我嘗試使用以下URL訪問控制器時,這是錯誤: http : //www.mywebsite.com/dev/controller

未找到

在此服務器上找不到請求的URL /dev/index.php/controller/。

我已經嘗試過.htaccess和config.php的每種組合,但是我不知道出了什么問題。

但是, http: //www.mywebsite.com/dev/可以正常工作。

這是.htaccess文件:

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

和application / config / config.php文件:

$config['base_url']     = '/dev/'; # I tried to put the whole path, didn't work either
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING'; # I tried every possibility, none of them work
$config['url_suffix'] = '';

真正奇怪的是,這種精確的配置曾經可以在另一台服務器上工作,我今天移動了代碼,現在不起作用了...

任何想法 ?

您沒有在重寫規則中使用查詢字符串,而是在使用path info 嘗試將uri協議更改為:

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

如果仍然無法解決問題,請嘗試更改規則以附加查詢字符串:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?$0 [PT,L]
#                       ^------ a "?" here instead of "/"

並確保htaccess文件在dev目錄中。

試試吧

RewriteEngine On
RewriteBase /your_project_name/
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]

和賓果游戲

暫無
暫無

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

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