2012-03-19 6 views
0

MYのCodeIgnitor設定では、ベースURLが期待できるURLで404が返されますhttp://x.example.com/test/)。 CodeIgniterが/index.php/をすべてのURLに追加するのはなぜですか?

要求されたURL /index.php/foobar/177

が見つかりません

このサーバー上で見つかりませんでした:私は、URLなどのhttp://x.example.com/test/foobar/177を訪問しようとすると、私は以下の404を得ます。

私は(これはWebfactionである)私のWebサーバーのログを確認すると、それだけで言う:

[月3月19日午前12時23分45秒2012] [エラー] [クライアント12.34.56.78]ファイルがありませんない が存在する:

/var/www/html/no_app_on_root.htmlindex.phpファイルパスは、index.phpので連結されていること方法はありません、奇妙なのですか?ここで

は私の.htaccessです:

Options +FollowSymLinks 

# Set which file that's fetched if only directory is specified 
DirectoryIndex index.php index.html index.htm 

# don't list category structures 
Options -Indexes 

# don't display .htaccess files 
<Files .htaccess> 
order allow,deny 
deny from all 
</Files> 


<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

#Removes access to the system folder by users. 
#Additionally this will allow you to create a System.php controller, 
#previously this would not have been possible. 
#‘system’ can be replaced if you have renamed your system folder. 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php/$1 [L] 

#Checks to see if the user is attempting to access a valid file, 
#such as an image or css document, if this isn’t true it sends the 
#request to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
#This last condition enables access to the images and css folders, and the robots.txt file 
#Submitted by Michael Radlmaier (mradlmaier) 
RewriteCond $1 !^(index\.php|images|robots\.txt|css) 
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> 

私のroutes.php:

$route['default_controller'] = "home"; 
$route['404_override'] = ''; 

$route['foobar/177'] = "foobar/foobar_177"; 
$route['foobar/:num/add'] = "foobar/add"; 
$route['foobar/:num/review'] = "foobar/review"; 
$route['foobar/:num'] = "foobar"; 

私のconfig.php(はい、サイトはサブドメイン上のディレクトリにある):

$config['base_url'] = 'http://x.example.com/test/'; 

$config['index_page'] = ''; 

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

お試しください。http://stackoverflow.com/questions/9455757/how-can-i-avoid-index-php-from-url-in-codelgniter/9455829#9455829 –

答えて

0

URLからindex.phpを隠すための書き換えルール

RewriteRule ^(.*)$ /index.php/$1 [L] 

を/index.php/$1するすべての要求を送信し、それらのためのハンドラが存在しない、あなたは、特にあなたには、いくつかのURLがindex.php

+0

申し訳ありませんが、私はあなたを理解していません。 – BaUn

0

にリダイレクトされたくないことをApacheに伝える必要がありますデフォルトでは、index.phpファイルは、あなたのURLに含まれます:

mywebsite.com/index.php/stories 

あなたは簡単にいくつかの簡単なルールと.htaccessファイルを使用してこのファイルを削除することができます。ファイルで

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 
0

:ここではすべてが指定された項目以外にリダイレクトされている「負」の方法を使用して、このようなファイルの例を示し

編集config.phpのこの行:

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

そして、あなたの.htaccessファイルは、次のようになります。:

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

から

RewriteEngine On 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 
+0

私はdocrootからシステムフォルダとアプリケーションフォルダを移動しましたが、それは何も変わりませんか? – BaUn

+0

私は先に進み、2つの変更を試しました。私はまだ404を取得しますが、少なくともindex.phpはURLに挿入されていません: 要求されたURL/test/foobar/177がこのサーバ上に見つかりませんでした。 – BaUn

+0

これは、.htaccessファイルがROOTに見つからないか、または内部のコードが実行されないことを意味します。それについて確かめてください。 –

関連する問題