Forum Moderators: phranque
Working on a mobile phone sniffer -
I'm trying to catch default page requests for the directory that my .htaccess file is located within, but I dont want to catch all requests to images etc, which is happening with my current rules below.. So for example I want to catch requests for [localhost...] but not [localhost...] Basically needs to exactly match the current directory without hard coding of urls if possible..
RewriteCond %{HTTP_USER_AGENT} ^(Nokia¦SonyEricsson¦BlackBerry¦SymbianOS¦MOT¦SEC¦Mini) [NC]
RewriteCond %{THE_REQUEST} ^$ [NC] # this needs to only catch requests for the current folders default page and not catch requests for style sheets, images etc..
RewriteRule ^(.*)$ index.php?mobile=$1 [QSA,L]
RewriteCond %{HTTP_USER_AGENT} ^(Nokia¦SonyEricsson¦BlackBerry¦SymbianOS¦MOT¦SEC¦Mini) [NC]
RewriteRule ^$ index.php?mobile=%1 [QSA,L]
Jim
[1][edited by: jdMorgan at 12:09 am (utc) on Aug. 29, 2008]
In some cases, you're better off looking for generic stuff like "Profile/MIDP-[0-9.]+\ configuration/CLDC-[0-9.]+" instead of trying to nail down specific devices at the mod_rewrite level. If you haven't been supporting mobile devices for very long, you're about to learn that their user-agent strings are a total mess -- The makers don't follow the standards for defining user-agent strings, and even change their own "standard" between their own makes and models! Good luck - I'm still trying to figure them out myself.
Jim