2

こんにちは、次のコードを使用してモバイル Web サイトにリダイレクトしました。モバイルからモバイル Web サイト、domain.com から m.domain.com では正常に動作しますが、URL の末尾に「?id=9」が来ています。を削除する方法

 ?id=9 

URL から。また、モバイル ウェブサイト m.domain.com をデスクトップ ブラウザから domain.com にリダイレクトする方法。以下のコードは、ウェブサイトをモバイルからモバイル webiste m.domain.com にのみリダイレクトします。

# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]

# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]

# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [S=1]

# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera  mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile}       !^$

# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie}        !\mobile=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.example.com%{REQUEST_URI} [R,L]
4

1 に答える 1

3

?次のように、ターゲット URL のクエリ文字列の追加を削除するには:

RewriteRule ^ http://m.example.com%{REQUEST_URI}? [R,L]
于 2013-06-08T15:10:16.000 に答える