0

私は Codeigniter 1.7.2 の初心者です。サイトURLのindex.phpとメソッド名を飛ばしたい。しかし、それらをスキップする方法がわかりません。私のサイトのURLは次のようになります-

http://localhost/mysadagi_voicetongues/index.php/deal_bazaar/PrivilegeDealsbazaar

だから私はURLからindex.phpとPrivilegeDealsbazaarをスキップしたい.

この問題を解決するための解決策を教えてください。

ありがとう

4

3 に答える 3

0

CI 2.1.3 で最新バージョンを使用する .htaccess を使用して、URL から index.php を隠すことができます。次の .htaccess を使用できます

<IfModule mod_rewrite.c>
   RewriteEngine On
    #AddHandler application/x-httpd-php5 .php
    RewriteBase /projectforlder/

    RewriteCond %{REQUEST_URI} ^system.*
    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>

URLで指定しないとコントローラーにアクセスできません。

于 2013-04-10T10:02:56.577 に答える
0

3 つのステップでこれを行うことができます。

1) アプリケーション ホルダーと並行して .htacess ファイルを作成し、次のコードをコピーするだけです。

RewriteEngine On
RewriteBase /CodeIgniter/       /* this will be your prj name. Change it as per your directory structure*/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

2) 以下のように、アプリケーション フォルダーの config.php で $config['index_page'] を空白に変更します。

$config['index_page'] = '';

3) Apache の「rewrite_module」を有効にします。

于 2013-04-10T10:03:10.620 に答える
0

言い忘れます。設定ファイル application/config/config.php を開き、この行を変更します

$config['index_page'] = “index.php”

$config['index_page'] = “”

アプリのルートに .htaccess ファイルを作成して、

  • システム
  • 応用
  • 資産
  • .htaccess

URL から index.php を削除するには、次の .htaccess ファイルを使用します。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^LoginTut.*
RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css|captcha)

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

コントローラー名を非表示にすることはあまり良い考えではありません。ルーティングや他の関数へのリンクの際に多くの問題が発生するためです。

それが役に立てば幸い!

于 2013-04-10T10:00:59.460 に答える