Feature request - Redirect Permanent Customizable

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

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

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.

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.

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 /

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 ..