Forum Moderators: phranque

Message Too Old, No Replies

Apache Document Type interpretation

How can I get proper interpretation?

         

mattmcl1

10:48 am on May 25, 2006 (gmt 0)

10+ Year Member



Hi - I am developing a site using mod_rewrite to create dynamic pages. It works like this:

http://www.example.com/Albany+New_York/ actually calls
http://www.example.com/sitepage.php?urldata=Albany+New_York

I have all the DB lookups working and pulling data into the page and now it has finally come time to design the site!

Here is the problem...I am using CSS to break my page into grids for ease of design.

I have verified that the following two URL's produce the exact same page source:
http://www.example.com/sitepage.php?urldata=Albany+New_York
http://www.example.com/Albany+New_York/

However, the first (sitepage.php in address bar) interprets the css correctly and the second (no explicit document type in the address bar) does not interpret the CSS correctly and the formatting doesn't work.

I am an Apache newbie but theorize that it isn't interpreting the page type correctly as html?

Any help is GREATLY appreciated.

[edited by: jdMorgan at 1:02 pm (utc) on May 25, 2006]
[edit reason] Example.com [/edit]

jdMorgan

1:01 pm on May 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's probably just that the browser is resolving a relative path to the included CSS file incorrectly, since the URL directory base is different. The fastest fix (and a good quick test) is to refer to the CSS file using a server-relative or canonical URL, instead of a page-relative URL. E.G. use:

<style type="text/css">@import url(/iestyle.css);</style>
-or-
<style type="text/css">@import url(http://www.example.com/iestyle.css);</style>

instead of

<style type="text/css">@import url(iestyle.css);</style>

It is the client (browser) that resolves relative URLs; If you've fooled it by using mod_rewrite or content negotiation to change the actual URL-to-filename mapping, it will generate incorrect URL requests (these should be visible in your server access logs).

If the links are relative, as in the third line above, then the CSS file would be called at

http://www.example.com/iestyle.css
http://www.example.com/Albany+New_York/iestyle.css

respectively for the two URL examples you posted, because the browser doesn't know that /Albany+New_York is a 'virtual' and non-existent directory; It just uses conventional URL-manipulation rules to remove the current "filename" and add the given relative path in every case for relative URL resolution.

Jim

mattmcl1

1:53 pm on May 25, 2006 (gmt 0)

10+ Year Member



Jim

Thanks again for prompt response. It worked!

- Matt