簡體   English   中英

從Code Igniter移除index.php

[英]Removing index.php from Code Igniter

我已經搜索了我的問題,但尚未看到與我類似的問題。

我的服務器上有一個新安裝的CI,出於安全原因,我已將“ application”和“ system”文件夾移到public_html之外,並移入了一個名為“ app”的文件夾。 我嘗試了很多論壇使用的方法,但似乎沒有幫助。

以下是我的文件夾結構,想知道.htaccess的類型以及該.htaccess的輸入位置?

/
app (system and application folder for CI resides here)
public_html (index.php - the one which defines ENVIRONMENT, styles, other htmls and my current .htaccess resides here)

我當前的.htaccess如下所示:

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

請幫忙! 感謝您的時間!

編輯當前我的網址是這樣的xxx.xxx.xxx.xxx/~app/index.php/user/check/id(位於共享主機上,但尚未鏈接到域,因此該網址中的IP地址和分區。)

我想實現類似xxx.xxx.xxx.xxx/~app/user/check/id的功能,並且在我鏈接域時應該可以使用。 (例如,www.mydomain.com / user / check / id)

好吧,我想我已經解決了問題。

這很可能與我擁有的“唯一”網址有關。 我認為如果這是一個普通域名,那么應該不會有太多問題。

我的網址> xxx.xxx.xxx.xxx/~app/index.php/user/check/id

我的目錄結構保持不變>

/ app(應用程序和系統目錄位於此處)

/public_html(index.php和.htaccess在這里)

.htaccess代碼如下:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~app/                        << NOTE the addition
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

在config.php中,設置

$config['base_url'] = 'http://xxx.xxx.xxx.xxx/~app/';
$config['index_page'] = '';

就這樣!

暫無
暫無

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

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