September 22, 2008

HTACCESS tech help, please

I reenabled the googlebot, and now it's trying to traverse that non-existent file tree again.

I want to add a rule to my .htaccess file. This is what I think it should say:

RewriteCond %{REQUEST_FILENAME} /Chizumatic/cref.shtml/.*$ [NC]
RewriteRule \.shtml$ /common/404.html [R,L]

Except that "REQUEST_FILENAME" isn't the right keyword to use in the first line. What I want is the request filepath, instead. Is "REQUEST_FILEPATH" the right keyword, or is it something else?

The Apache documentation for HTACCESS is a travesty, by the way. Just thought I'd mention that.

Posted by: Steven Den Beste in Site Stuff at 10:35 PM | Comments (11) | Add Comment
Post contains 90 words, total size 1 kb.

1 I've read comments to the effect that the documentation for Apache is mainly the code. Not trying to hijack the thread here, but this, of course, is one of the things people gripe about WRT open source. (And plenty of closed source software has the same problem.)

Posted by: RickC at September 23, 2008 06:13 AM (p1CHu)

2

I once got behind the 8-ball with my boss because he thought the MS Access '97 Users Manual was suffcient documentation to be able to write a program to parse text input, discarding bad results in VBA -- and I failed to do so.  The episode contributed significantly to a stall in my career.

Software: the only "engineering" discipline wherein structural failure isn't just tolerated, it's expected.

As for the .htaccess I have even less idea, sorry.

Posted by: ubu at September 23, 2008 06:43 AM (dhRpo)

3 Noticed something interesting today: I have been reading Chizumatic on and off for a week or so via Opera Mini on my WinMo smartphone. When I do, I get the "no bandwidth theft" logo instead of the banner image at the top of the page.

Posted by: RickC at September 23, 2008 06:55 AM (p1CHu)

4 Firstly I don't quite understand how .htaccess got involved into something that affects the whole document tree and should be in httpd.conf. Secondly, why use mod_rewrite at all? I would just match against a pattern using something like DirectoryMatch and then "Deny all". And finally, the root cause seems to be something in the configuration that generates the recursion in the first place. Why not fix that instead? Just a thought. I don't have a lot of experience configuring webservers.

Posted by: Pete Zaitcev at September 23, 2008 07:08 AM (/ppBw)

5

Firstly I don't quite understand how .htaccess got involved into something that affects the whole document tree and should be in httpd.conf. Secondly, why use mod_rewrite at all?

Because it's already on, in order to prevent LiveJournal and Fark users from deep-linking my graphics files.

I would just match against a pattern using something like DirectoryMatch and then "Deny all".

Good for you, but I don't know how to do that.

And finally, the root cause seems to be something in the configuration that generates the recursion in the first place. Why not fix that instead? Just a thought. I don't have a lot of experience configuring webservers.

Neither do I, and that's the problem.

Noticed something interesting today: I have been reading Chizumatic on and off for a week or so via Opera Mini on my WinMo smartphone. When I do, I get the "no bandwidth theft" logo instead of the banner image at the top of the page.

The top rotation picture is hosted on my own server, not on Pixy's. If you don't send one of a small number of explicitly permitted referers, you get the "don't steal bandwidth" image instead of the real top rotation picture.

Probably your browser, or your proxy, are lousing up the referer.

Posted by: Steven Den Beste at September 23, 2008 09:56 AM (+rSRq)

6

"The top rotation picture is hosted on my own server, not on Pixy's. If you don't send one of a small number of explicitly permitted referers, you get the "don't steal bandwidth" image instead of the real top rotation picture."

Yep, I knew that. I figured it was likely either a proxy error or something wrong with opera mini.  If you have any interest in examining your logs, I hit the site today, last monday, and a couple of other days last week, around 5AM your time.  (The only reason I mention it is if it turns out the referer is ok, I might file a bugrep with the Opera folks.)

Posted by: RickC at September 23, 2008 10:10 AM (fZUrq)

7
Except that "REQUEST_FILENAME" isn't the right keyword to use in the first line.


I think REQUEST_URI is what you want.

Or, for a one-liner, this should do it:

RewriteRule ^/?Chizumatic/cref.shtml/ - [F,L,NC]

The "^" means to match against the start of the string (so it wouldn't match /foo/Chiz... for example), and the question-mark is because depending on whether you're using this in an .htaccess file or in the .conf file, the leading slash may be implied -- I forget, so the question-mark makes it work either way.  The "F" means "return a 'forbidden' error", and the "L" means "if this matches, then make it the last rule we process for this request."

Posted by: Anthony DiSante at September 23, 2008 10:49 AM (xJ4r5)

8

"REQUEST_URI"

Did you mean "URI" or "URL"?

Posted by: Steven Den Beste at September 23, 2008 12:57 PM (+rSRq)

9 URI.

Posted by: AnthonyDiSante at September 23, 2008 01:36 PM (xJ4r5)

10 Your one-liner seems to work perfectly. Thank you very much for your help!

Posted by: Steven Den Beste at September 23, 2008 02:56 PM (+rSRq)

11 You're welcome!  I've been frustrated many times by that horrible Apache documentation, so I'm glad to share what I've learned to spare someone from having to spend any more time in those docs.

Posted by: AnthonyDiSante at September 23, 2008 03:46 PM (xJ4r5)

Hide Comments | Add Comment

Enclose all spoilers in spoiler tags:
      [spoiler]your spoiler here[/spoiler]
Spoilers which are not properly tagged will be ruthlessly deleted on sight.
Also, I hate unsolicited suggestions and advice. (Even when you think you're being funny.)

At Chizumatic, we take pride in being incomplete, incorrect, inconsistent, and unfair. We do all of them deliberately.

How to put links in your comment

Comments are disabled. Post is locked.
11kb generated in CPU 0.0133, elapsed 0.0301 seconds.
20 queries taking 0.0212 seconds, 28 records returned.
Powered by Minx 1.1.6c-pink.