Helpful Information
 
 
Category: Mobile Programming
accessing hdml pages through apache...

In apache (virtually hosted), I want to have an index.html page that browsers will load automatically, and an index.wml page that my mobile browser will load automatically. Unfortunately, when I access the site through my handset, it continues to load the index.html page. (I have added the new extension types to the .htaccess file, if that makes any difference.) What can I do?

Arrange the order of it.

i.e. DirectoryIndex index.wml index.html

I assumed that using the DirectoryIndex directive in this fashion would mean that browsers would (intuitively?)skip over the index.wml and go to the index.html. However, all that I get is a prompt for what application I should use to open index.wml, which is obviously not what I want. (Also, going to the site now using the handset results in a "Web Service Problem:..." message).

Oh, I now see what the problem is. So are there any unique environment variable accessing from your mobile browser? Maybe the HTTP_USER_AGENT?
If so, you can use mod_rewrite to _External_ redirect the requests that match such HTTP_USER_AGENT to http://www.domain.com/index.wml while leaving others to http://www.domain.com/index.html or just http://www.domain.com/

I read through the mod_rewrite documentation, and it seems a little daunting (all those regular expressions). Does the regex engine follow the same rules as the Perl regex engine I am familiar with? I am starting to think it may be easier to php3-ize the index page, then have it redirect any weird user-agents to the index.wml file.

>>Does the regex engine follow the same rules as the Perl regex engine

Yes

>>php3-ize the index page, then have it redirect any weird user-agents to the index.wml file

The right approach, it should load much faster, since mod_rewrite is flexible and powerful but slow.

I asked you for the HTTP_USER_AGENT of your mobile browser but you haven't provided me that, so I am unable to write the mod_rewrite rulesets for you.

Sure! The user agent is "UP.Browser/3.01-QC12 UP.Link/3.2.3.7" .

Okay, place this to http://www.domain.com/.htaccess

#############################################

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^UP.Browser/.*
RewriteRule ^$ index.wml [L]

#############################################

Such RewriteRule matches requests to the following URLs with your UP.Browser useragent:
http://www.domain.com/ or http://www.domain.com

and Internal redirect to http://www.domain.com/index.wml What Internal means is that the user sees http://www.domain.com/ instead of http://www.domain.com/index.wml

For all other wml page requests, your index.wml page more than likely will have a link to those other pages, in this case, such request will not follow the rewrite rule set.

RewriteRule ^$ matches any request that starts with nothing and ends with nothing, that is basically a request of http://www.domain.com or http://www.domain.com/
If someone requests http://www.domain.com/index.wml directly, then it will ignore the ruleset.

If you want request http://www.domain.com or http://www.domain.com/ to redirect to http://www.domain.com/index.wml (what user sees), then use External redirect. That is, replacing the [L] with [R,L].

[This message has been edited by freebsd (edited October 10, 2000).]










privacy (GDPR)