rack-rewrite is a Rack middleware that provides URL rewrite rules to Rack apps. It is a little bit like mod_rewrite for Apache.
Questions tagged [rack-rewrite]
21 questions
4
votes
4 answers
How to use gem rack-rewrite to 301 redirect for full URL from naked domain to www domain
I have a Rails 2.3.2 Application hosted on Heroku.
The naked domain and the www subdomain were added years ago and they both have some authority for search engines.
However the problem is that search engines are seeing the content as duplicate so I…

chell
- 7,646
- 16
- 74
- 140
3
votes
3 answers
Need to link WP Blog with Rails App on Heroku
I have a client who wants to migrate his Rails app to Heroku. However the client also has a blog associated with his domain that runs on WordPress. Currently, the WordPress blog is running happily alongside the Rails app, but once we migrate to…

John Glass
- 368
- 2
- 8
2
votes
1 answer
How do I use rack rewrite to add www to a url?
I want to redirect my rails app to add www to the url if the user doesn't use it. I found this site to remove it, but I would like to do the opposite:
http://steve.dynedge.co.uk/2010/03/03/using-rackrewrite-to-remove-the-www/

NotDan
- 31,709
- 36
- 116
- 156
2
votes
1 answer
Rewrite dynamic URLs with multiple variables from ransack filter
I am building a little project in Ruby on Rails (which I am fairly new in using).
The idea ist to have a little listing website where users can filter all listings according to country and category.
I realized the filter using the gem ransack and…

Freebian
- 107
- 11
2
votes
2 answers
Rewrite URL from Subdirectory to Subdomain in Rails for Heroku
I'm trying to rewrite:
mysite.com/blog to blog.mysite.com
To be clear: I only want the user to see mysite.com/blog .Where the blog is actually a separately hosted wordpress site at blog.mysite.com. And mysite.com is a Rails app.
I have attempted to…

andyleesuk
- 110
- 10
2
votes
1 answer
rack-rewrite - rails3.2 - heroku - redirect hardcoded image urls
My images were all held in the app itself and so were referenced with /images/12345.jpg which in some places has been hard coded into the content of the cms, with or without the full url.
The images have now been moved to s3 and so I want to add a…

dp6ai
- 41
- 3
2
votes
1 answer
Adding a querystring to rack-rewrite response
I've got a simple 301 redirect to capture all non .com domains I have registered for my site as follows:
DOMAIN = 'www.mywebsite.com'
use Rack::Rewrite do
r301 %r{.*}, "http://#{DOMAIN}$&", :if => Proc.new {|rack_env|
rack_env['SERVER_NAME']…

Les
- 1,405
- 15
- 27
2
votes
1 answer
rack-rewrite redirect ALL subdomains to root domain (except root)
How do this:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
in rack-rewrite syntax?

Greg Betr
- 21
- 3
2
votes
1 answer
How to rewrite to a different domain using rack-rewrite?
I want to make a rewrite to another domain so that http://domain1.com/abc would point to http://domain2.com/xyz. This is my code:
require 'rack/rewrite'
config.middleware.insert_before(Rack::Lock, Rack::Rewrite) do
rewrite '/abc',…

sNiCKY
- 1,823
- 3
- 18
- 20
2
votes
1 answer
Rails: Proper setup with DNS, Rack-rewrite etc for Heroku
I have looked all over the internet but could not get one final solution to what I would expect to be the 100% proper setup of DNS etc to get the following result on Heroku.com:
Using a mydomain.com to show the content at…

Christoffer
- 2,271
- 3
- 26
- 57
1
vote
0 answers
Rewriting periods following the TLD using Rack::Rewrite
I'm using the rack-rewrite gem to rewrite my urls in a Rails app.
One of the problems I want to avoid is having a trailing period after the TLD.
http://example.com./foo
^
Now I'm not 100% sure if this matters for google juice or…

Ben Scheirman
- 40,531
- 21
- 102
- 137
1
vote
1 answer
How do I use rack-rewrite to remove .html (if the file exists)?
I'm not a Rubyist, but I do rather like Jekyll and the ease of which I can spin up a "blog enabled" site in combination with Heroku and Git.
I'm wanting to use Rack-Rewrite (or if there is something better to do the same, I'm happy to use that) to…

Paul Jenkins
- 993
- 1
- 11
- 19
1
vote
1 answer
Regex in Rack-Rewrite redirecting more than it should
I have a redirect setup like so:
r302 %r{(/example/.*)}i, 'http://new-domain.com/$1'
For this URL http://example.com/example it works great redirecting to http://new-domain.com/example
I would like to adapt this regex (or expression) to not…

Neil Hoff
- 2,025
- 4
- 29
- 53
1
vote
1 answer
Proper config for rack-rewrite with unicorn for local dev and heroku
I'm trying to figure out how to properly setup rack-rewrite and am having some trouble. I'm a bit of a noob and the site isn't super clear on the setup. I have a couple of questions if anyone knows more about it.
1) Do I need to put the gem in both…

Eric Norcross
- 4,177
- 4
- 28
- 53
1
vote
3 answers
rack-rewrite code to redirect https to http (on heroku)
Somehow Google indexed my homepage as https://mydomain.com. When you do a site:mydomain.com search, the first result is https://mydomain.com and I don't have a SSL cert and don't want to do https. Now our visitors get the ugly warnings in their…

pentor
- 11
- 2