login community faq

I have a webfaction Static/CGI/PHP-5.3 site that was migrated from a different host's Apache. It had a rewrite rule:

1
2
3
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]

That Nginx is not seeing. How can I get this working so a url like example.com/foo fetches foo.html from disk?

This old forum post does not seem encouraging: http://forum.webfaction.com/viewtopic.php?id=3931 The Nginx magic presumably I can look up, but how to get it working on webfaction is more murky.

asked Oct 10 '12 at 20:51

brycenesbitt's gravatar image

brycenesbitt
34

edited Oct 10 '12 at 20:54


On WebFaction under a Static/CGI/PHP application, your site isn't being run by Nginx - it's still being run by Apache, so you definitely want to use the Apache rewrite rule. (see diagram here)

Looking at this rule, you may need a "RewriteBase /" directive before the RewriteCond, but without looking at the application more closely it's difficult to debug.

As for Nginx rewrite rules, if you are actually running your website under an Nginx instance (for example, if you're using Django with uWSGI under Nginx), then you should be able to use them exactly as described in the Nginx documentation.

answered Oct 10 '12 at 21:08

ryans's gravatar image

ryans ♦♦
28411420

edited Oct 10 '12 at 21:12

The Apache code above ran perfectly for many years.

The webfaction control panel shows the site as Static/CGI/PHP on /. But when I use "wget -S" I see "200 OK Server: nginx". And .htaccess files don't work. So is it Nginx or Apache serving this stuff?

If this is indeed Nginx how do I insert configuration into it?

(Oct 10 '12 at 21:53) brycenesbitt brycenesbitt's gravatar image

This is because everything is hosted behind an nginx proxy, it is really apache which is hosting the PHP. This image will illustrate.

(Oct 10 '12 at 22:01) johns ♦♦ johns's gravatar image

No .htaccess directives are working, not even a simple:

RedirectMatch 404 ^robots.txt

Though I swear they worked at one point.

(Oct 10 '12 at 22:35) brycenesbitt brycenesbitt's gravatar image

If you're moving the site from another host to WebFaction, sometimes differences in the apache configuration can mean that rewrite rules and other directives have to be tweaked. However, do you mean that this used to work on WebFaction and no longer does? We haven't made any significant changes to Apache which should have broken these rules.

If you are indeed moving the site from another webhost to WebFaction, please open a support ticket so we can take a look at the actual site. I can certainly guarantee that our servers support .htaccess files and that mod_rewrite is enabled on our servers.

(Oct 10 '12 at 23:05) ryans ♦♦ ryans's gravatar image

Based on the context of this issue, the rule needed to be:

1
2
3
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_URI}.html [L

In case anyone encounters this problem in the future, this is related to the way that the DocumentRoot is set (to "$HOME/webapps/_") for website records which mount more than one application to them. Using "%{REQUEST_URI}" in the RewriteRule directive should work under both scenarios.

Hope that helps!

answered Oct 11 '12 at 00:51

ryans's gravatar image

ryans ♦♦
28411420

One thing I've noticed is that Webfaction servers require RewriteBase /

answered Oct 11 '12 at 06:22

epqrs's gravatar image

epqrs
335

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×149
×127
×1

Asked: Oct 10 '12 at 20:51

Seen: 581 times

Last updated: Oct 11 '12 at 06:22

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited