|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Member
Join Date: Nov 2009
Posts: 1
|
I'm redirecting the iPhone (and soon to be more mobile devices) successfully but in combination with some preexisting rewrite rules in my .htaccess file it's causing too many redirects.
The mobile site is at mydomain.com/m and from mydomain.com it's trying to go to mydomain.com/m/?page=m&page=m&page=m&page=m etc. I'm new to mod_rewrite and any help you could offer would be great! Thanks! ![]() Code:
### REDIRECT MOBILE DEVICES
RewriteCond %{HTTP_USER_AGENT} ^(.*iPhone.*)$
RewriteCond %{REQUEST_URI} !^/m
RewriteRule ^(.*)$ /m [L]
### OTHER REQUIRED REWRITE RULES BELOW
### CHECK FOR TRAILING SLASH - Will ignore files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ /$1/ [L,R=301]
### MAIN REWRITE - This will ignore directories
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\/$ /index.php?page=$1&%{QUERY_STRING} [L]
|
|
|
|
|
|
#2 |
|
Hosting
![]() ![]() ![]() ![]() Join Date: Feb 2002
Location: Auckland
Posts: 11,065
|
Ben,
Well, the mod_rewrite for WAP-enabled phones used to be to echo a doctype in the file itself: Code:
RewriteCond %{HTTP_ACCEPT} text/vnd\.wap\.wml
Your code is fine for what it's trying to do UNTIL you get to the blocks after the iPhone. There, you must provide an exclusion for your m/ directory. Your last block will loop because you're only checking for the existence of a directory, not a file (which means that index.php is matched and you'll loop). Regards, DK |
|
|
|
|
|
#3 |
|
SitePoint Member
Join Date: Nov 2009
Posts: 1
|
Hi,
there is a project called "Apache Mobile Filter" that allows you to access WURFL from any programming language, not just Java and php that is traditionally used for dynamic mobile web sites. The module detects the mobile device and passes the WURFL capabilities on to the other web application as environment variables. It can also be used to resize images on the fly to adapt to the screen size of the mobile device. Now this module is one of modules included in Apache Module Registry (modules.apache.org) For more info search "Apache Mobile Filter" on google Last edited by dklynn; Nov 22, 2009 at 14:57. Reason: The URL is moduleS.apache.org and link added for members |
|
|
|
![]() |
| Bookmarks |
| Tags |
| mod_rewrite |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 13:02.













Linear Mode
