I have a site where Ruby on Rails is running at the root directory via Phusion Passenger. Some Apache Alias
directives serve static HTML directories.
If you request an exact URL of a file from one of the static directories, Apache returns it as expected. However, there are a few cases where I'm not getting the expected behavior. Consider the alias Alias /functional /path/to/functional
, where the functional directory contains index.php and hello.jpg .
If I add an index.html file into the functional directory (in addition to the index.php that is already there), paths #3 and #4 return that file as expected.
Here's the relevant parts from my Apache configuration file for Passenger:
LoadModule passenger_module /path/to/mod_passenger.so
LoadModule ssl_module modules/mod_ssl.so
<IfModule mod_passenger.c>
# ... passenger setup stuff omitted ...
Listen 443
<VirtualHost *:443>
ServerName ...
DocumentRoot /path/to/rails/public
PassengerRuby /path/to/ruby
<Directory /path/to/rails/public>
Allow from all
Options -MultiViews
</Directory>
# ... ssl setup omitted ...
</VirtualHost>
</IfModule>
And for the static directories:
Alias /functional /path/to/functional/
Alias /phpMyAdmin /path/to/phpMyAdmin/
# ... other aliases omitted ...
<Directory /path/to/functional>
DirectoryIndex index.php
AllowOverride all
</Directory>
I've tried most of the answers in index.php not loading by default to make index.php load, to no prevail. I shouldn't even need to specify DirectoryIndex index.php
since that line is already in conf.d/php.conf .
Any ideas on how to solve this issue where Rails is giving 404s on URLs which are supposed to be going elsewhere in the Apache stack?
Have you tried replacing
<Directory /path/to/functional>
With
<Directory /functional>
I had the same problem. The working solution was just a RedirectMatch
statement in the virtualhost serving passenger as follows:
RedirectMatch ^/path/to/functional(/)?$ /path/to/functional/index.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.