Scott Walter
2007-Mar-25 02:30 UTC
[Mongrel] Can''t seem to get rewrite rules to work with Apache
Hi, I''m struggling to get an Apache rewrite rule to work. I have a simple rule that for a request to "a.html" will be sent to "b.html". However the requests for "a.html" are always sent to my Rails apps. Here is my Apache configuration: <VirtualHost 216.154.219.19:80> <Directory /u/apps/simplelog_2.0.2/public/> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all DirectoryIndex index.php index.html </Directory> ServerName scottwalter.com DocumentRoot /u/apps/simplelog_2.0.2/public SuexecUserGroup webadmin webadmin RewriteEngine On RewriteRule ^a\.html$ b.html ProxyPass / http://127.0.0.1:3002/ ProxyPassReverse / http://127.0.0.1:3002/ ProxyPreserveHost on ServerAlias "www.scottwalter.com" ServerAdmin "support at scottwalter.com" CustomLog "/u/apps/simplelog_2.0.2/log/access_log" "combined" ErrorLog "/u/apps/simplelog_2.0.2/log/error_log" </VirtualHost> Does anyone have any ideas?
Patrick Berry
2007-Mar-25 17:07 UTC
[Mongrel] Can''t seem to get rewrite rules to work with Apache
On 3/24/07, Scott Walter <sw-ng at scottwalter.com> wrote:> > Hi, > > I''m struggling to get an Apache rewrite rule to work. I have a > simple rule that for a request to "a.html" will be sent to "b.html". > However the requests for "a.html" are always sent to my Rails apps. > Here is my Apache configuration: > > <VirtualHost 216.154.219.19:80> >RewriteRule ^a\.html$ b.html> </VirtualHost> > > Does anyone have any ideas?If I''m not mistaken you need to tell Apache what to do when the first part of the rule matches. RewriteRule ^a\.html$ b.html [R] Pat -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070325/f7443ac3/attachment-0001.html
Vincent Bray
2007-Mar-26 08:58 UTC
[Mongrel] Can''t seem to get rewrite rules to work with Apache
On 25/03/07, Scott Walter <sw-ng at scottwalter.com> wrote:> Here is my Apache configuration: > > <VirtualHost 216.154.219.19:80>[snip]> RewriteEngine On > RewriteRule ^a\.html$ b.html[snip]> </VirtualHost>Because your rule is in vhost context (and not in your Directory block) you must include the leading slash. You may also want to bypass the ProxyPass, or switch to using [P] instead. ProxyPass /a.html ! ProxyPass /b.html ! ProxyPass / http://127.0.0.1:3002/ ProxyPassReverse / http://127.0.0.1:3002/ ProxyPreserveHost On RewriteEngine On RewriteRule ^/a.html /b.html .. or .. RewriteEngine On RewriteCond %{REQUEST_URI} !^(a|b)\.html RewriteRule . http://127.0.0.1:3002%{REQUEST_URI} [P] ProxyPassReverse / http://127.0.0.1:3002/ ProxyPreserveHost On I suspect this question really belongs on an apache support list. -- noodl
Scott Walter
2007-Mar-26 13:14 UTC
[Mongrel] Can''t seem to get rewrite rules to work with Apache
Yeah I know this question probably didn''t belong here, but I figured some other "Mongrels" have had similar issues and I thought I''d give it a try. Good thing too because your help worked like a champ! Thanks. scott. On Mar 26, 2007, at 3:58 AM, Vincent Bray wrote:> On 25/03/07, Scott Walter <sw-ng at scottwalter.com> wrote: >> Here is my Apache configuration: >> >> <VirtualHost 216.154.219.19:80> > [snip] >> RewriteEngine On >> RewriteRule ^a\.html$ b.html > [snip] >> </VirtualHost> > > Because your rule is in vhost context (and not in your Directory > block) you must include the leading slash. You may also want to bypass > the ProxyPass, or switch to using [P] instead. > > ProxyPass /a.html ! > ProxyPass /b.html ! > ProxyPass / http://127.0.0.1:3002/ > ProxyPassReverse / http://127.0.0.1:3002/ > ProxyPreserveHost On > RewriteEngine On > RewriteRule ^/a.html /b.html > > .. or .. > > RewriteEngine On > RewriteCond %{REQUEST_URI} !^(a|b)\.html > RewriteRule . http://127.0.0.1:3002%{REQUEST_URI} [P] > ProxyPassReverse / http://127.0.0.1:3002/ > ProxyPreserveHost On > > I suspect this question really belongs on an apache support list. > > -- > noodl > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users