Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I've got a simple web.py application, running at Dreamhost. The .htaccess file, per the DH documentation is in the example.com home directory, not public:

Options +ExecCGI
AddHandler cgi-script .py
DirectoryIndex index.py/
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /public/
  RewriteCond %{REQUEST_URI} !^/favicon.ico$
  RewriteCond %{REQUEST_URI} !^/static/(.*)$
  RewriteCond %{REQUEST_URI} !^(/.*)+index.py/
  RewriteRule ^(.*)$ /index.py/$1 [PT]
</IfModule>

When I try to access the page, however, I get

67.165.250.93 - - [12/Sep/2011:19:40:38 -0700] "GET /index.py/ HTTP/1.1" 200 678 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" 
67.165.250.93 - - [12/Sep/2011:19:40:39 -0700] "GET /index.py/static/reset.css HTTP/1.1" 404 255 "http://www.microscopy.salveteomnis.com/index.py/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" 
67.165.250.93 - - [12/Sep/2011:19:40:40 -0700] "GET /index.py/static/common.css HTTP/1.1" 404 256 "http://www.microscopy.salveteomnis.com/index.py/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" 
67.165.250.93 - - [12/Sep/2011:19:40:40 -0700] "GET /index.py/static/microscope-large.jpg HTTP/1.1" 404 256 "http://www.microscopy.salveteomnis.com/index.py/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" 

It's clear that this isn't being rewritten correctly -- the static contents should be /static/foo -- but I've been unsuccessful fixing the problem.

share|improve this question
    
Where this .htaccess is located? In website root folder (example.com/.htaccess) .. or example.com/public/.htaccess ? –  LazyOne Sep 13 '11 at 7:37
    
What precisely are you expecting? And what's your log format string? –  Peter Taylor Sep 13 '11 at 8:22
    
@LazyOne, it's in the example.com directory. –  Charlie Martin Sep 13 '11 at 22:28
    
@Peter, this is on a Dreamhost host, I've got no clue what the log format string is offhand. It's not under my control. –  Charlie Martin Sep 13 '11 at 22:29
    
That was the less important of my two questions... On the basis of the information you've posted so far, the problem could be in your HTML and completely unrelated to the Apache config. –  Peter Taylor Sep 13 '11 at 22:46
show 1 more comment

1 Answer

The more I look at this the more I'm convinced that your problem is completely unrelated to the rewrite rule. The 5th and 6th fields of your log look like the actual request made by the client and the response code:

"GET /index.py/ HTTP/1.1" 200
"GET /index.py/static/reset.css HTTP/1.1" 404
"GET /index.py/static/common.css HTTP/1.1" 404
"GET /index.py/static/microscope-large.jpg HTTP/1.1" 404

So it's successfully getting /index.py/ and then requesting /index.py/static/reset.css. The obvious explanation for this is that the HTML returned for /index.py/ includes

<link type="text/css" rel="stylesheet" href="static/reset.css" />

when it should be

<link type="text/css" rel="stylesheet" href="/static/reset.css" />

PS Although one thing does strike me as odd about the rewrite rule. Are you sure the rule itself shouldn't be

  RewriteRule ^(.*)$ /index.py?$1 [PT]

?

share|improve this answer
    
Well, if I knew what the RewriteRule should be I wouldn't be in this mess. The thing is that the exact same code, html and all, runs fine as a standalone web.py app; it's when I'm trying to run it as a cgi app at Dreamhost that it fails. BTW, trying the /static version still fails. Thanks for the thought though. –  Charlie Martin Sep 14 '11 at 15:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.