2016-09-08 8 views
0

私はrewriteemapを使ってmod rewriteリダイレクトを書こうとしていますが、私の正規表現に問題があります。私は、古いURLの各検索パラメータを分離し、対応するクエリパラメータにマップする必要があります。私の計画は、ユーザーが1,2,3の検索パラメータを持っているかどうかに応じて3つの別々のルールを持つことです。私は現在、ユーザーが1つの検索パラメータを持っている場合に正規表現を作成しようとしていますが、問題が発生しています。Mod Rewrite RewriteMap Regex - 検索パラメータ

正規表現:/store/search/([^/]*)^((?!/).)

また、私は、ユーザーが複数の検索パラメータを入力したとき、私のマップを再利用することができていますか疑問に思って。私が使用する必要があり

# Desired redirects: 
http://www.my-host.com/store/search/small => http://www.my-host.com/store/search?q=tall 
http://www.my-host.com/store/search/medium/low-calorie => http://www.my-host.com/store/search?q=grande,healthy 
http://www.my-host.com/store/search/medium/low-calorie/brown => http://www.my-host.com/store/search?q=grande,healthy,chocolate 

RewriteMap searchMap txt:/opt/etc/apache/conf/searchMap.txt 
RewriteCond ${searchMap:$1|$1} ^(.*)$ 
RewriteRule "/store/search/([^/]*)^((?!/).)" "http://%{HTTP_HOST}/store/search?q=%1" [NC,R,L] 

# searchMap.txt 
small tall 
medium grande 
low-fat healthy 
low-calorie healthy 
brown chocolate 
pink strawberry 
+0

'/ small'は' Q = tall'のために行くのだろうか? :P – hjpotter92

+1

@ hjpotter92 'small' =>' tall' – Jon

答えて

0

正しい正規表現は次のとおりです。

/store/search/([^/]*)$ 
/store/search/([^/]*)/([^/]*)$ 
/store/search/([^/]*)/([^/]*)/([^/]*)$ 
+0

More _specific_ regexは 'RewriteRule'sの最初に現れます – hjpotter92

+0

逆の順序でそれらを持っているのですか? – Jon

+0

はい............ – hjpotter92

関連する問題