1

私は何百もの異なるコードをテストしましたが、それらは機能し、他の何かを台無しにするか、まったく機能しません。これは怠惰に聞こえますが、私は実際に何百もの組み合わせを試しました.

「モバイル」サブドメイン (モバイルエージェントの検出) にリダイレクトしたいメインドメインと、持っている .html ページのフォルダーがあります。両方のディレクトリがファイル名に関して一致します。

私に何かアイデアはありますか?

4

1 に答える 1

1

ブラウザのユーザー エージェント文字列に基づいてリダイレクトする方法に関する情報が記載された Web サイトを次に示します。

http://www.howtoforge.com/apache2-how-to-redirect-users-to-mobile-or-normal-web-site-based-on-device-using-mod_rewrite

.htaccess は次のようになります。

RewriteEngine On

# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)noredirect=true(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]

# Check if this looks like a mobile device
# (You could add another [OR] to the second one and add in what you
#  had to check, but I believe most mobile devices should send at
#  least one of these headers)
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:Profile}       !^$
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^mobile\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie}        !\smredir=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://mobile.jguffphotography.com/%{REQUEST_URI} [R,L]

上記の最新のコードに更新してください。

上記のコードをすべて更新して、どのように見えるべきかを反映させました。

于 2012-07-04T03:31:45.400 に答える