2012-04-10 10 views
0

表示からファイルを防ぎ、と私は.htaccessファイル を作成することにより、URLからのindex.phpを削除しようとしましたが、それ内容:URL(CodeIgniterの)からのindex.phpを取り除くの.htaccess私はCodeIgniterのを使用してい

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

この方法ではxamppサーバーで作業します。 私はサイトをアップロードしたときに残念ながら問題が発生しました:

私はfilesというフォルダとcontentサブフォルダ:images、css、js、swf、uploadを持っています。 これらのフォルダにあるすべてのファイルは表示できず、ブラウザにはファイルが見つかりませんでした。

help ploese

+0

エラーログには何が表示されますか? – Sedz

答えて

1

は、私はあなたの問題を解決すると思うこれを試してみてくださいホープ:

RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/css|files\/js|files\/swf|files\/upload) 
+0

私は最後のファイルと作業ファイルを使用していただきありがとうございます。私はすべてのサブディレクトリを置くべきですか?サブディレクトリがたくさんあるフォルダがある別のサイトがあり、index.phpの近くに存在するメインディレクトリの名前だけを入れようとしましたが、それはうまく動作しませんでした。 –

+0

はい、あなたは、PHPが処理したくないサブフォルダ/フォルダをすべてインクルードする必要があります。 – zaherg

2

ちょうどあなたがあまりにもそれらを除外することを確認してください:ここで

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

は私の.htaccessファイルである - あなたのために働く必要があります。これは私の.htaccessファイルである

Options -Indexes 
Options +FollowSymLinks 

# Set the default file for indexes 
DirectoryIndex index.php 

<IfModule mod_rewrite.c> 

    # activate URL rewriting 
    RewriteEngine on 

    # do not rewrite links to the documentation, assets and public files 
    RewriteCond $1 !^(files|css|js|swfimages|assets|uploads|captcha) 

    # do not rewrite for php files in the document root, robots.txt or the maintenance page 
    RewriteCond $1 !^([^\..]+\.php|robots\.txt|crossdomain\.xml|maintenance\.html) 

    # but rewrite everything else 
    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. 
    ErrorDocument 404 index.php 
</IfModule> 
2

。私が理解しているのは、アクセスしようとしていて存在しないファイルまたはディレクトリに対して、Codeigniterに転送することです。

存在するものはすべて問題なく動作し、個別除外は必要ありません。これにより、新しいディレクトリやフォルダを追加するたびにこのファイルを編集する必要がなくなり、時間と労力を節約できます。

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

私のために働いていますが、私の理解は間違っている可能性があります。あなたがindex.phpにかけてそれらのディレクトリを処理しないようにサーバーに指示する必要があり、これのための作業ラインである

RewriteEngine on 
RewriteCond $1 !^(index\.php|robots\.txt|files\/images|files\/css|files\/js|files\/swf|files\/upload) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

...それは

+0

ありがとうございます。これはうまくいった。 私は別のウェブサイトと次のindex.phpを持っています。私はファイルと呼ばれるフォルダを持っています、そして、この1つのコンテンツの多くは、それらのすべての名前とサブディレクトリの名前を入れなければなりませんか? –

+0

なぜこれ以上upvotedされていないかわからない、これまでのところ最高の解決策です。 – StackOverflowed

1

ありがとうございます。これはうまく働いた:

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

を私はファイルという名前のフォルダがあり、フォルダのこの1つのコンテンツたくさん私はすべてのそれらの名前とサブディレクトリの名前を入れて持っている必要があり、他のウェブサイトと、次のindex.phpを持っていますそれら?

関連する問題