2016-03-26 8 views
0

私はcodeigniterの新機能を利用しています。私は自分のローカルサイトからindex.phpを削除することに頭を抱えようとしています。ホームページにも同様の質問がありますが、完全に機能しているわけではありません。自分のサイトの別のページにアクセスするたびに、画面にワンプページが表示されます。ここに私のコードは、CodeIgniterのである/の.htaccessCodeigniter mod-rewrite from apache、index.phpを削除する

<IfModule mod_rewrite.c> 
RewriteEngine On 
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading 
# slashes. 
# If your page resides at 
# http://www.example.com/mypage/test1 
# then use 
# RewriteBase /mypage/test1/ 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
# If we don't have mod_rewrite installed, all 404's 
# can be sent to index.php, and everything works as normal. 
# Submitted by: ElliotHaughin 

ErrorDocument 404 /index.php 
</IfModule> 

私はまた私のapache/confに入れている/ httpd.confの

<Directory /> 
    Options Indexes FollowSymLinks 
    AllowOverride All 
    Require all granted 
</Directory> 

しかし、まだ運が、私が見逃しているものがありませんか? 1.変更するには、このような設定ファイル::次の.htaccess 2.Use

$config['index_page'] = ''; 

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

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

注:.htaccessがによって異なり事前に感謝は

答えて

0

次のステップに従ってくださいサーバ。 I一部のサーバー(例えば:GoDaddyは)は、次の.htaccessを使用する必要があります。ほとんどのサーバー上でこの.htaccessの作品

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

注:バージョン3に問題がある場合は、[いいえ](https://github.com/bcit-ci/CodeIgniter/blob/develop/application/config/config.php#L40)の[AUTO] uriプロトコル。 – Tpojka

+0

すばやい返信をいただきありがとうございます。私はこれをやっており、現在はホームページ以外のページを読み込むたびに404エラーが発生します。 Apacheで何かする必要はありますか? mod-rewriteを有効にしました – Hides

+0

[config](https://github.com/bcit-ci/CodeIgniter/blob/develop/application/config/config.php#L6)ファイルで 'base_url()'を設定しましたか? – Tpojka

0

使用

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 
# RewriteCond %{HTTPS} off 
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

あなたはHTTPSを強制するために、最後の2行のコメントを解除することができます。

また、これはまた、第二の.htaccess

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /foldername/ 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L]       
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule>       
<IfModule !mod_rewrite.c> 
ErrorDocument 404 /index.php 
</IfModule> 

注ライン3でRewriteBase /フォルダ名/の仕事ができるスクリプトがフォルダ名を含めずに到達することができる場合は、このでRewriteBase/を使用しています。

関連する問題