phusion / passenger

A fast and robust web server and application server for Ruby, Python and Node.js
https://www.phusionpassenger.com/
MIT License
4.99k stars 548 forks source link

mod_rewrite incompatibility problem #873

Open FooBarWidget opened 10 years ago

FooBarWidget commented 10 years ago

From frankske on June 08, 2012 17:21:08

What steps will reproduce the problem?

  1. Create a file bar.txt in your public/ documentroot
  2. Put "RewriteEngine On RewriteRule foo$ /bar.txt" in your .htaccess (wipe first, if one exists)
  3. hit http://hostname/foo in your brower

What is the expected output? What do you see instead?

Expected result: get contents of bar.txt Result instead: rails 404 error, and "Started GET "/bar.txt" in rails log

It seems the rewriting from foo to bar.txt works, but still gets passed to Passenger, while it should be server the bar.txt static instead.

Only way to get it to work at the moment, is by passing [R] to force Apache to rewrite the URL, but that requires extra HTTP hit.

What version of Phusion Passenger are you using? Which version of Rails? On what operating system?

Passenger version is 3.0.12, OS is Debian stable, ruby 1.9.3p0

Original issue: http://code.google.com/p/phusion-passenger/issues/detail?id=774

FooBarWidget commented 10 years ago

From zabojnik@dextronet.com on June 20, 2012 01:26:48

It is the exact same problem we are now having.

I'd mark that as a High priority issue since it effectively disables using html cache - you cannot rewrite any request to say cache/$1.html in your public directory because it hits the rails app and returns 404!

FooBarWidget commented 10 years ago

From zabojnik@dextronet.com on June 20, 2012 01:29:35

Our setup: Phusion Passenger (mod_rails/mod_rack) 3.0.2, ruby 1.8.7 (2008-08-11 patchlevel 72), Linux version 3.1.9-vs2.3.2.5, Debian 4.4.5-8

FooBarWidget commented 10 years ago

From Wesley.Spikes on June 27, 2012 10:45:27

We encountered this in our environment and were able to reproduce it given the steps provided in the first comment.

In our testing, we found that we were able to work around this by adding "PassengerHighPerformance on" in the APPROOT/.htaccess file.

This is strange, since the documentation suggests that turning it on would break mod_rewrite, but it actually fixed it!

FooBarWidget commented 10 years ago

From frankske on June 27, 2012 11:02:04

yes! I can confirm that solution provided in comment 3 works!

FooBarWidget commented 10 years ago

From honglilai on February 04, 2013 10:41:08

Being compatible with mod_rewrite is very difficult. I guess there are still some bugs that need to be fixed.

Summary: mod_rewrite incompatibility problem (was: Apache rewrite to file still goes to passenger)