2016-09-22 16 views
2

Codeigniterのurlから "index.php"を削除しようとしています。 index.phpをbase URLから削除する方法を知っています(example.com/controller)。codeigniter index.phpフォームのURLを削除する

しかし、私はCodeIgniterの中に別のプロジェクトに持っているのでexample.com/folder/index.php/controller

のようにサブフォルダ内の「index.phpを」を削除する方法がわかりません。ので、私はサブフォルダにアップロードされた2番目のプロジェクト。

の.htaccess

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

#modify 
RewriteEngine on 

RewriteCond $1 !^(index\.php|resources|robots\.txt) 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !-d 

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

RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] 

ベースURLの上記のプログラム。ですから、私はこのプログラムで何が変わるのかは、サブフォルダで動作します。

答えて

0

書き込みこのコード

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /folder/index.php [L] 
</IfModule> 

# END WordPress 

例です上記のコードの後に​​contorller

それが働いている

はindex.php書き込みする必要はありません。..

+0

ありがとう...それは働いています – joy

+0

あなたの歓迎.... – Gagan

0

この変数をconfig.phpで更新します。$config['index_page'] = ''; -2あなたのCodeIgniterのフォルダに移動し、.htaccessファイルを作成します:index.phpの

$config['index_page'] = "" 

ステップを削除する// index.php

+0

これだけでは、あなたのURLからindex.phpを削除されません、次のようなmod_rewriteのいくつかのフォームを使用する必要があります。ヒットアクセスファイルを適切に削除する必要があります。 – killstreet

0
`Step:-1 Open the file config.php located in application/config path. Find and Replace the below code in config.php file. 

//以下のコードを探す

$config['index_page'] = "index.php" 

を削除します。

パス:

Your_website_folder/ 
    application/ 
    assets/ 
    system/ 
    user_guide/ 
    .htaccess <--------- this file 
    index.php 
    license.txt 

ステップ:-3 .htaccessファイル内のコードの下に書く

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

ステップ:-4いくつかのケースではuri_protocolのデフォルト設定は動作しません。正しく。この問題を解決するには、単にアプリケーション/ configにあるファイルconfig.phpファイルを開き、ように、コードを検索と置換:

//以下のコード

$config['uri_protocol'] = "AUTO" 

//を探す

として、それを交換してください
$config['uri_protocol'] = "REQUEST_URI" ` 
+0

さん、あなたのロジックが動作していません.. – joy

0

example.comのフォルダで行ったのと全く同じ手順で、example.com/folderフォルダのベースURLからindex.phpを削除します。 example.com/folder/index.php/:それは、あなたの.htaccessファイル編集/ configファイルからのindex.phpを削除し、htaccessファイルを作成するなど