Submitted by Mobika on Mon, 10/29/2012 - 09:53
Greetings,
we're in need of having the possibility of customizing the "Alias -> Redirect Permanent" into the "Server Templates -> Apache Website" area of VirtualMin.
Specifically, we'd like to specify a full custom rewrite rules for 301/302 Redirects aka Alias Domains, in order to be able to not to only permanently redirect the merely domain but also all that other parameters and whatever else following the root ( / ) URL.
Status:
Active
Comments
Submitted by Mobika on Mon, 10/29/2012 - 11:24 Comment #1
We'd like to add an example of how we'd like to be able to add custom rewrite rules for Alias Domains:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^rehost\.it
RewriteRule ^(.*)$ http://www.rehost.it/$1 [R=301,L]
We're actually using this kind of rewriting on most if not all of our domains (manually edited obviously).
Awaiting a response from you, our best and kind regards.
Matteo Piccoli
Mobika srl
Submitted by JamieCameron on Mon, 10/29/2012 - 23:21 Comment #2
I'm a little confused as to what you want to do here ... are you looking for a way to redirect users who access http://example.com/ to http://www.example.com/ ? Or something else?
Submitted by Mobika on Tue, 10/30/2012 - 04:40 Comment #3
Hi Jamie,
we want to be able to customize the 301 Redirect.
Instead of using the RedirectPermanent directive, as VirtualMin sets actually, we'd like to add a Rewrite Rule of our own, for example to Redirect with a 301, but keeping all parameters passed in the URL.
Actually there's only a choice among 4 radios for 4 different behaviors in the Server Templates setup page.
Is it possible to have a 5th "Custom..." radio + a TextArea field where one can insert his own Redirect rules using mod_rewrite ?
Hope to be as much clearer as possible.
Kind regards, Matteo.
Submitted by JamieCameron on Tue, 10/30/2012 - 16:05 Comment #4
What if instead I just added an option to pass the original URL path on in the redirect?
Allowing the entering of arbitrary Apache directives is tricky, and has the potential to break the Apache configuration.
Submitted by Mobika on Wed, 10/31/2012 - 03:40 Comment #5
The matter is that I may have different options to pass in the URL query string so I should be able, at least, to use a regexp to isolate them and pass them to the new redirect target url (that's actually what you mean for breaking Apache configuration)
Anyway just to give you an example:
http://www.mobika.tel/pages/contacts?id=01 -> 301 to http://www.mobika.it/pages/contacts?id=01
RedirectPermanent won't let me the capability to pass anything after the .tel first /, everything gets discarded, while a RewriteCond + a RewriteRule will let me pass all the $N elements I can isolate after the first source URL /
Submitted by JamieCameron on Wed, 10/31/2012 - 15:39 Comment #6
You may want to look into creating a sub-server (not an alias) domain, then using the redirects feature at Server Configuration -> Website Redirects to create the redirect you want. This has an option to control if the original path is included or not ..