4 ms·
It is possible to do 301 redirects at the registrar level in a way that preserves the full path, including query strings? This is, I'd like to arrange for
by mhartl 12y ago
It is possible to do 301 redirects at the registrar level in a way that preserves the full path, including query strings? This is, I'd like to arrange for
example.com/home?a=foo&b=bar
to redirect to
www.example.com/home?a=foo&b=bar
Is there any way to do this without using something more specific like mod_rewrite?
- TazeTSchnitzel 12y agoWhat's wrong with mod_rewrite?
- mhartl 12y agoIt won't work at, e.g., Heroku.
- TazeTSchnitzel 12y agoSo? Your redirects don't need to be at Heroku.
- mhartl 12y agoSo what if my website is at Heroku?
- TazeTSchnitzel 12y agoWell, why use Heroku for redirection? That sounds like overkill. Your registrar may provide web hosting, or possibly forwarding.
- mhartl 12y agoYour registrar may provide . . . forwarding. And thus we return to my original question: Is there a way to do forwarding at the registrar level in a way that preserves the rest of the URL structure? If you're willing to work at a less general level than the registrar, a Ruby gem called Refraction used to work for forwarding in Rails projects (I used it for the Ruby on Rails Tutorial and The Tau Manifesto), but Refraction rules included in a recent Rails project (the most recent iteration of http://tauday.com/ http://tauday.com/) were seemingly ignored. Some Googling revealed a couple of possible more up-to-date solutions: https://github.com/cwninja/rack-force_domain https://github.com/cwninja/rack-force_domain https://github.com/tylerhunt/rack-canonical-host https://github.com/tylerhunt/rack-canonical-host I have yet to try them out, but they look promising. As an aside, when someone asks a question of the form "How do I do X without feature Y?", it's rarely helpful to respond with something like "Why not use Y?" Typically, the person asking the question has a reason for not using Y, and by making not using Y part of the question they're trying to avoid exactly the kind of digression that happened in this thread. EDIT (because HN won't let me reply): I agree that it's sometimes worth understanding why they want to do X without Y, but it's best done with a lightness of touch. Otherwise you risk not giving the asker the benefit of the doubt (e.g., via statements like "So? Your redirects don't need to be at Heroku."). It's usually better to either answer the original question as stated or tread very carefully, with phrasing like "I'd like to understand your reasons for not wanting to use Y" rather than the blunter "What's wrong with Y?" UPDATE: I can confirm that [rack-canonical-host](https://github.com/tylerhunt/rack-canonical-host https://github.com/tylerhunt/rack-canonical-host) does the kind of forwarding I wanted, as you can verify by visiting, e.g., http://tauday.com/tau-manifesto?foo=bar http://tauday.com/tau-manifesto?foo=bar, which is correctly forwarded to http://www.tauday.com/tau-manifesto?foo=bar http://www.tauday.com/tau-manifesto?foo=bar.
- TazeTSchnitzel 12y ago> And thus we return to my original question: Is there a way to do forwarding at the registrar level in a way that preserves the rest of the URL structure? Depends on your registrar. > As an aside, when someone asks a question of the form "How do I do X without feature Y?", it's rarely helpful to respond with something like "Why not use Y?" Typically, the person asking the question has a reason for not using Y, and by making not using Y part of the question they're trying to avoid exactly the kind of digression that happened in this thread. Sure, but it is sometimes worth asking why someone wants to know how to do X without Y.
- jboggan 12y agohttps://devcenter.heroku.com/articles/route-53 https://devcenter.heroku.com/articles/route-53 This works pretty well and sets up quickly; it uses AWS Route 53 to provide 301 redirects automatically.