2012-02-29 11 views
0

私はhtaccessファイルにこの書き換えコードを持っていますが、lighttpdに変換する必要があります。私はlighttpdでモバイルリダイレクトを行う必要があります

次は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 %{REQUEST_URI} !^/m/.*$ 
RewriteCond %{REQUEST_URI} !^/xml/.*$ 

RewriteCond %{HTTP_ACCEPT} "text/vnd.wap.wml|application/vnd.wap.xhtml+xml" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR] 
RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC] 
RewriteCond %{HTTP_USER_AGENT} !macintosh [NC] #*SEE NOTE BELOW 

# Check to make sure we haven't set the cookie before 
RewriteCond %{HTTP:Cookie}  !\smredir=0(;|$) 
# Now redirect to the mobile site 
RewriteRule^http://%{SERVER_NAME}/m%{REQUEST_URI} [R,L] 

私は、コードを書き換えてみました。それはデスクトップ上の永続的なリダイレクトに私を置くようであり、モバイルには影響を受けません。

はここで、これまでlighttpdのコードです:

server.modules += ("mod_redirect") 

$HTTP["url"] !~ "^/xml/.*$" { 
    $HTTP["url"] !~ "^/m/.*$" { 
     $HTTP["useragent"] =~ "(acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv|palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda|xda-|up.browser|up.link|windowssce|iemobile|mini|mmp|symbian|midp|wap|phone|pocket|mobile|pda|psp)" { 
      $HTTP["useragent"] !~ "macintosh" { 
       $HTTP["host"] =~ "(.*)" { 
        url.redirect = ("^/(.*)" => "http://%1/m/$1") 
       } 
      } 
     } 
    } 
} 

答えて

1

私は自分のサーバー上でこのコードを使用します。

希望すると助かります!

## normal version of site 
$HTTP["host"] == "example.com" { 
    $HTTP["useragent"] =~ "(Android|iPhone|Palm|BlackBerry)" { 
      url.redirect = ("^/(.*)" => "http://m.example.com/$1") 
    } 
} 
## mobile version of site 
$HTTP["host"] == "m.example.com" { 
    $HTTP["useragent"] !~ "(Android|iPhone|Palm|BlackBerry)" { 
      url.redirect = ("^/(.*)" => "http://example.com/$1") 
    } 
} 
関連する問題