2016-07-05 13 views
1

システムにロックされています... 私のconfig.phpファイルの設定を、パラメータを持つURLに変更しました。 突然、URLパラメータを渡すIDを表示する製品コントローラがあります。CodeIgniter URL書き換えが機能しません

http://localhost:8888/mywebsite/index.php?c=product&m=index&id_product=12

このURLは今、私はタイプのURLを取得したい作品:

http://localhost:8888/mywebsite/product/my-product-12

だから私は.htaccessファイルでこれを置く:

RewriteRule ^product/([a-zA-Z0-9\-]+)-([0-9]+).html$ index.php?c=product&m=index&id_product=$2 [L] 

しかし、ページが表示されます:要求されたURL /index.php/product/my-product-12.htmlではありませんでした on thiサーバー。

私のhtaccessファイル:

#Options +FollowSymLinks 
RewriteEngine on 
RewriteBase/

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

RewriteRule ^product/([a-zA-Z0-9\-]+)-([0-9]+).html$ index.php?c=product&m=index&id_product=$2 [L] 

マイconfig.phpファイル:

<?php 

$config['base_url'] = 'http://localhost:8888/mywebsite/'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'QUERY_STRING'; 
$config['url_suffix'] = ''; 
$config['enable_hooks'] = TRUE; 
$config['allow_get_array']  = TRUE; 
$config['enable_query_strings'] = TRUE; 
$config['controller_trigger'] = 'c'; 
$config['function_trigger']  = 'm'; 
$config['directory_trigger'] = 'd'; 
$config['rewrite_short_tags'] = FALSE; 

?> 

答えて

0

でRewriteBase後に新しいのRewriteRuleを入れて:

RewriteEngine on 
RewriteBase/

RewriteRule ^product/([a-zA-Z0-9\-]+)-([0-9]+)$ index.php?c=product&m=index&id_product=$2 [L] 

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

をあなたが最初に書き換える必要があるため〜index.php?c=product

+0

あなたの答えをありがとう! 私のページにこのエラーメッセージがあります: が見つかりません 要求されたURL /index.phpはこのサーバー上に見つかりませんでした。 – xenos92

+0

'.html'なしで今すぐお試しください。それはあなたのコードにありましたが、あなたのexempleのURLにはありませんでした。 – Croises

+0

同じ結果...理解できない:( – xenos92

関連する問題