Forum Moderators: DixonJones

Message Too Old, No Replies

.htaccess rule for off-line browser - stylesheets

requests for Page%20Name_file/style.css

         

stevenha

4:41 pm on Aug 3, 2003 (gmt 0)

10+ Year Member



In my error log, there are requests for my stylesheet, that come in the form *_files/style.css , where the * is the <title> text of a page, and the spaces in the title text were converted to %20s

I gather ( but am not entirely sure), that these things occur, when the user uses the "Save as" command to save a copy of my webpage to his/her local disk, and then views the local page. Its apparently a problem that occurs because "Save as" didn't correctly rewrite the "@import" type of stylesheet syntax that is commonly used.

Now that I've cleaned up my error logs in other ways, by handling exploits in .htaccess, these off-line stylesheet requests have now become a noticable irritating cause of errors.

So I add this bit of code to my .htaccess:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# Fix off-line browser requests for my styles.css
RewriteCond %{REQUEST_URI} \_files/styles\.css$
RewriteRule .* /styles.css [L]

And that seems to be working. But I post it here, in case there are other variations on the off-line browser - stylesheet theme, where others might care to suggest improvements. (I'm still learning, eh?)

Brett_Tabke

11:57 am on Aug 25, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



hmmm.

Anyone else have experience with the above? Why would the browser modify the style sheet during "save as"?

wkitty42

11:35 pm on Aug 26, 2003 (gmt 0)

10+ Year Member



i can't say that i've had or seen this problem... then again, i just went live with my stylesheet version of my site...

is the error happening /when/ the user saves the page or is it when they try to access the page after saving it?

TTBOMK, IE saves pages in the format stevenha wrote... page_name_files\files_in_page

i don't think that the actual css file is being changed but the html files are being "localized" for the saved copy... its possible that the @import is being missed by the browser's save function... how is that @import coded in your pages, stevenha?

stevenha

12:48 am on Aug 27, 2003 (gmt 0)

10+ Year Member



Thanks for replying. Here's a few more comments. For a while, I had accumulated several variations of the rules for off-line browsers. The original was for requests that asked for <title>_files/style.css, then I added some foreign language variations (which I can't remember right now, but instead of "_files", it was something like a german word for folder or briefcase, and a spanish word too). But then I realized it would be simpler to replace the rule with this:

# Fix off-line browser requests for my style.css
RewriteCond %{REQUEST_URI} ./stylies\.css$
RewriteRule .* /stylies.css [L]

And that seems to work for all the variations.

wkitty24 asked about the format of my @import statements. This is what I've been using.

<style type="text/css" media="all">@import "../style.css";</style>

Yes, I believe that when "Save as" tries to localize the html page ( that it is saving localling on the users hard disk), it seems to mis-interpret the "@import" part. The bad requests then seem to come when they later try to view the page they saved to their hard disk.

wkitty42

1:00 am on Aug 27, 2003 (gmt 0)

10+ Year Member



the first thing i see is "../style.css" and that's kinda what i was looking for... is ".." back to the root of your directory tree? if so, you should be able to change those references to "/style.css"...

i noticed this type of behavior with some wysiwyg editors... i used to use dreamweaver and when linking to pages and/or images, it would offer a choice between relative to the site or relative to the page... relative to the page gave me references like your "../style.css" stuff...