2

私は小さなCMSに取り組んでおり、すべての元のディレクトリを目的のディレクトリに変更しRewriteRuleましたhtaccess。また、モバイルデバイスユーザー用のモバイルテンプレートを追加します。したがって、私のWebサイトには2つのディレクトリがあります。1つはコンピュータクライアント用、もう1つはモバイルクライアント用です。次のコードを使用してモバイルエージェントを検出し、モバイルテンプレートにリダイレクトしますが、ループエラーが発生します。

これは私のリダイレクトコードです:

RewriteCond %{REQUEST_URI} !^/m/.*$
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /m/ [L,R=302]

これは私の現在のhtaccessです:

Options +FollowSymLinks
RewriteEngine On
# Change main URL 
RewriteRule ^m/ /mobile/index.php [QSA]
# Change content URL
RewriteRule ^/a/m/([a-zA-Z0-9\.]+)$ /mobile/index.php?pid=$1 [QSA]
4

1 に答える 1

1

URI が書き換えられた URI ( /mobile/...) ではないことも確認する必要があります。%{THE_REQUEST}に対してチェックするか、チェックを含めることでそれを行うことができます/mobile

RewriteCond %{THE_REQUEST} !\ /m/.*
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /m/ [L,R=302]

また:

RewriteCond %{REQUEST_URI} !^/a/m/.*$
RewriteCond %{REQUEST_URI} !^/m/.*$
RewriteCond %{REQUEST_URI} !^/mobile/.*$
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /m/ [L,R=302]
于 2012-12-27T11:45:15.897 に答える