You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by João Gil ACE-SC <jo...@edis.edp.pt> on 2004/09/21 12:07:30 UTC

[users@httpd] How to Configure Apache to detect browser and request apropriade Index.* file.

Greetings,

  Is it possible to configure apache to detect bowser type and depending on
  the browser, apache requests the apropriate index.* file. Eg it the
  browser is a WAP device apache would open index.wml else index.html. If
  it is possible what do I have to do?

  I have tried doing this using JSP. In an index.jsp file I would detect
  the browser and present the apropriate information. But when I tested it
  with my mobile phone I got "invalid file format" error. Looks to me that
  the file being requested by the WAP device has to have .wml extention.
  Therefo I think that the only solution is having apache request the
  correct file depending on the browser type.

  Thanks in advance for any help.

  Warmest Regards
  Joao Gil



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] How to Configure Apache to detect browser and request apropriade Index.* file.

Posted by Robert Andersson <ro...@profundis.nu>.
João Gil ACE-SC wrote:
>   Is it possible to configure apache to detect bowser type and depending
>   on the browser, apache requests the apropriate index.* file. Eg it the
>   browser is a WAP device apache would open index.wml else index.html.
>   If it is possible what do I have to do?

You can problably do it using BrowserMatch and env variables. Possibly also
simply using multiviews, but I'm not sure.

One way is using mod_rewrite. This very much depends on your site, but to
illustrate:

RewriteCond %{USER_AGENT} WAP
RewriteRule (.*)\.html $1\.wml

How to safely match a WAP device, I don't know. See:
http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html#rewritecond
http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html#rewriterule

Content-negotiation (multiviews) is another possibilty, beacuse the client
should send Accept-* request headers indicated supported formats etc, and
then Apache selects the most appropriate version of the resource. How this
could work with WAP devices, I don't know. See:
http://httpd.apache.org/docs-2.0/content-negotiation.html

Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org