PDA

View Full Version : .wml, mod_rewrite and mime-types


JoeRT
09-28-2000, 10:37 PM
I'm trying to use mod_rewrite to do, as it says in the docs, "On-the-fly Content-Regeneration".[nbsp][nbsp]It works great when I try to do it with my regular browser, but all the mobile simulators say it's the wrong mime-type even though I've added the mime-type to an .htaccess file everyplace I can think of (the directory of the page I'm trying to create, the cgi-bin directory, etc.).[nbsp][nbsp]Anyone have any idea why it's still returning the wrong mime-type?[nbsp][nbsp]More importantly, how can I get it to return the right mime-type?

-------------------
Joe Torsitano
www.weatherforyou.com (http://www.weatherforyou.com)

JoeRT
10-03-2000, 04:45 PM
Anyone?[nbsp][nbsp]Please?

Terra
10-03-2000, 05:14 PM
Wish I could, but this one is out of my league... ;)

Point me to the actual MIME type specification and I will look into installing it into our MIME core...

This way, you won't have to worry about overriding with .htaccess...

--
Terra
--I looked at your question and had not an answer for either--
FutureQuest

JoeRT
10-03-2000, 10:45 PM
Well I don't know if this is what you need, but this is what I'm told by the error message I get...

add the following 5 mime-types to the server configuration file.

[nbsp]Content[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] MIME type[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]Extension
[nbsp]--------------------------------------------------------------------
[nbsp]WML source[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] text/vnd.wap.wml[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] Wml
[nbsp]Compiled WML[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]Application/vnd.wap.wmlc[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]Wmlc
[nbsp]WMLScript source[nbsp][nbsp][nbsp][nbsp] text/vnd.wap.wmlscript[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] Wmls
[nbsp]Compiled WMLScript[nbsp][nbsp]Application/vnd.wap.wmlscriptc[nbsp][nbsp][nbsp][nbsp] Wmlsc
[nbsp]Wireless bitmap[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]image/vnd.wap.wbmp[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]wbmp

Let me know if this isn't what you need, and I'll go searching.

Thanks!

-----------------
Joe Torsitano
www.weatherforyou.com (http://www.weatherforyou.com)

Justin
10-04-2000, 05:15 AM
You can add those easily within an .htaccess file. Check out this tutorial (http://service.futurequest.net/tech/support/solution?11=000318-0001&130=0953412982) for more help. Keep in mind that file extentions are Case Sensitive, so if you have index.wml, but you specified .Wml (as you show above), these are seen as two distinct file extentions with their own MIME types.

------------------
Justin Nelson
FutureQuest (http://www.FutureQuest.net/index.php) Support

Terra
10-04-2000, 06:28 AM
Before I add these, which the demand has warranted adding the WAP MIME anyways, I am concerned that you have your Extensions capitalized...

These are case sensitive, and 'Wml' != 'wml'

Please take a moment to double check the listing you presented...

--
Terra
sysAdmin
FutureQuest

JoeRT
10-04-2000, 09:58 AM
Justin,

Read my post that started this whole thread... .htaccess isn't working in this case.[nbsp][nbsp];)[nbsp][nbsp] While adding the mime types to the server config will be the overall fix, if you have an .htaccess solution I'd be glad to try it.[nbsp][nbsp]I'm using the .htaccess solution elsewhere and it works great, but not in this situation.

TeRRa... I just copied that from the error message that I got from the WAP simulator... don't know why they used upper case.[nbsp][nbsp]I would think extensions should be all one case, and I always use all lower (.html, .shtml, .wml, etc.).[nbsp][nbsp]In the places on my site where I'm already effectively using WAP/.wml I'm using lower case.

Thanks!

--------------------
Joe Torsitano
www.weatherforyou.com (http://www.weatherforyou.com)

Justin
10-04-2000, 02:06 PM
Read my post that started this whole thread... .htaccess isn't working in this case. There is no reason this wouldn't work via .htaccess. If it doesn't work there, it will not work in the server config either ;)

The only thing I can suggest is to:

1) Make sure you are using the same case
2) Double check that the .htaccess file ends with a line feed
3) Make sure the file was uploaded in ASCII/text mode
4) Make sure it resides in the proper directory, either the directory containing the files, or one above it
5) Make sure your "AddType" directive is also in proper case

If all of the above are observed, there is no reason this would not solve this problem. The AddType directive instructs Apache to treat files ending with a particular extention as a particular content type, and it passes this information along to the browser. This would be no different that adding it into the server core, so if this isn't working for you, I don't see a core config being the solution either...

------------------
Justin Nelson
FutureQuest (http://www.FutureQuest.net/index.php) Support

JoeRT
10-04-2000, 03:19 PM
Make sure it resides in the proper directory But when using mod_rewrite on a CGI script, what is the proper directory?[nbsp][nbsp]I tried /cgi-bin, the directory I'm doing the mod_rewrite from and a couple other places.[nbsp][nbsp]Does the mod_rewrite instructions need to go before/after the AddType instructions?[nbsp][nbsp]I'm using static .wml pages in those same directories with no problems... just the mod_rewrite ones won't work.

--------------
Joe Torsitano
www.weatherforyou.com (http://www.weatherforyou.com)

PaulKroll
10-04-2000, 03:38 PM
If you have a CGI script returning a document, the CGI script is responsible for sending the mime-type: are you sure your script is doing this? If not, that would explain a lot. :)

Justin
10-04-2000, 04:21 PM
PaulKroll is correct. MIME types will only apply to the static .wml page, regardless of whether or not it's in the server core. The script is responsible for sending the correct MIME type. I'm willing to bet your script is printing:
</font><font face="Courier" size="3">
Content-type: text/html
</font><font face="Verdana, Arial" size="2">
Followed by two blank lines. 99.9% of all scripts will print this somewhere near the top of the script. Simply change the content type to the desired type (</font><font face="Courier" size="3">Content-type: text/vnd.wap.wml</font><font face="Verdana, Arial" size="2">, for example).

PS - mod_rewrite is not needed here, either. The script itself needs to generate the headers, not the web server. If you need to dynamically figure out which header to send, simply use (assuming Perl) </font><font face="Courier" size="3">$ENV{'HTTP_USER_AGENT'}</font><font face="Verdana, Arial" size="2"> to determine what is being used to access the page...

------------------
Justin Nelson
FutureQuest (http://www.FutureQuest.net/index.php) Support
[This message has been edited by Justin (edited 10-04-00@4:23 pm)]

JoeRT
10-04-2000, 05:03 PM
Well I changed all references to Content-type: text/html to Content-type: text/vnd.wap.wml in the script and in the template it generates... no difference.[nbsp][nbsp]Reason I was using mod_rewrite is the error message from the simulator keeps saying it's looking for a file with .wml as it's extension, not .cgi.

Any other ideas gratefully appreciated and tested while you wait... right after I pick up my son from school.[nbsp][nbsp]:)

----------------
Joe Torsitano
www.weatherforyou.com (http://www.weatherforyou.com)

Justin
10-04-2000, 06:28 PM
Ok, in that case, what is the exact URL your handheld (or emulator) is requesting? If it is looking for a .wml page in your cgi-bin, try making a copy of the script, with the name ending in wml. Remember, this is Unix - anything in the cgi-bin is a script, regardless of file extention.

What you're apparently getting is a 404 error... it seems the handheld is looking for a specific file instead of what you're requesting. I've never used one (nor have I tried the emulators yet), so I have no experience in how they handle URLs. It appears from your description that the handheld itself handles the rewrite, changing whatever you type into a .wml link...

If that's not the case, I give... You might be better off trying to find a forum/newsgroup relating to authoring for handhelds, and asking others for suggestions on how they were able to accomplish this task.

------------------
Justin Nelson
FutureQuest (http://www.FutureQuest.net/index.php) Support

Terra
10-04-2000, 06:43 PM
Before I core the new MIME types, I want to localize to one server only for testing...

Which server/account are these MIME(s) for?

--
Terra
sysAdmin
FutureQuest

JoeRT
10-04-2000, 07:45 PM
I got it to work![nbsp][nbsp]I don't know if you've already changed something on the server, but I made some fairly drastic changes in a few places and it worked on both simulators![nbsp][nbsp]Justin, it was a lot your clue about the script returning the content header... I hadn't even thought about that because the content header is in the template the script uses.[nbsp][nbsp]But the script also sends content header info.

TeRRa... if you still want to investigate adding the MIME type, I guess I have to submit my site as a guinea pig since I brought it up.[nbsp][nbsp]:P[nbsp][nbsp]weatherforyou.com on NINE.

THANK YOU EVERYONE! :)

---------------------
Joe Torsitano
www.weatherforyou.com (http://www.weatherforyou.com)

Terra
10-04-2000, 08:20 PM
I have just discovered how easy it is to transpose characters with the 'vnd', 'wap', etc. typing...

Your brain get's stuck on a wap wap wap trend where p's and d's start to blur...

I have typed everything in and triple checked the settings...[nbsp][nbsp]BTW: Application should be application or some browsers will get upset...

Please test it out, it's only active on x40 right now with full NINE propagation after tonights STATS run...

Total server migration in the next few days once it's proven on NINE...

--
Terra
--I remember the days when it was only TAZ I had to build on--
FutureQuest

JoeRT
10-04-2000, 08:58 PM
Works perfect![nbsp][nbsp]:)

I removed all the references in the .htacess files and all my static WAP/.wml applications passed on both simulators.[nbsp][nbsp]And since I got the dynamic ones to work earlier, I'm confident they still will once I make the final adaptions to the scripts.

Thank you very much, TeRRa and Justin... you're the best![nbsp][nbsp]:)

------------------
Joe Torsitano
www.weatherforyou.com (http://www.weatherforyou.com)