WebFaction
Community site: login 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:

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 10 Oct '12, 20:51

brycenesbitt
92819
accept rate: 0%

edited 10 Oct '12, 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.

permanent link

answered 10 Oct '12, 21:08

ryans ♦♦
5.0k93360
accept rate: 43%

edited 10 Oct '12, 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?

(10 Oct '12, 21:53) brycenesbitt

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

(10 Oct '12, 22:01) johns

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

RedirectMatch 404 ^robots.txt

Though I swear they worked at one point.

(10 Oct '12, 22:35) brycenesbitt

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.

(10 Oct '12, 23:05) ryans ♦♦

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

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!

permanent link

answered 11 Oct '12, 00:51

ryans ♦♦
5.0k93360
accept rate: 43%

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

permanent link

answered 11 Oct '12, 06:22

epqrs
16921231
accept rate: 0%

Your answer
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

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×225
×186
×1

question asked: 10 Oct '12, 20:51

question was seen: 4,030 times

last updated: 11 Oct '12, 06:22

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM