I wrote a way to redirect to a main url of choice, rather than the main site url. In the process of writing this functionality, I realized that I may not actually need this functionality, I found that aegir has "automatic" aliases, and that I just have to change my process to get Aegir to do what I want it to do.
I'm posting this code here in case anyone finds it useful, or thinks this might also be a good idea to have this functionality. Essentially it just gives you another field next to the aliases to type in the url that you want your site redirecting to, and defaults to the main site url.
Note from the Aegir maintainers:
This issue overlaps with:
Comment | File | Size | Author |
---|---|---|---|
#12 | provision.code_.1681904-12.patch | 1.77 KB | helmo |
#12 | hostmaster.code_.1681904-12.patch | 751 bytes | helmo |
#9 | redirects-1.jpg | 107.32 KB | omega8cc |
#9 | redirects-2.jpg | 91.9 KB | omega8cc |
#7 | hostmaster.code_.1681904-7.patch | 10.58 KB | helmo |
Comments
Comment #1
anarcat CreditAttribution: anarcat commentedBefore this is implemented, I would like to see this get in: #815190: Allow for both redirects and aliases.
Comment #2
anarcat CreditAttribution: anarcat commentedOh, and this will not hit 1.x.
Comment #2.0
Steven Jones CreditAttribution: Steven Jones commentedUpdated issue summary.
Comment #3
Jon PughI've rebuilt the site alias form to use single textfields, with a "Add More" Ajax button, and added a select list to choose the "redirection target".
I realized that I could use the {hosting_site_alias}.redirection column to store the desired target URI.
The attached patches includes an update hook to change the schema of redirect column to varchar, and handles sites.php, and the vhost file.
It works with the automatic domains as well.
I built this on 1.x to start, but if this has potential to get in, will rewrite it to work with 2.x. I am not sure why this feature has to wait for #815190: Allow for both redirects and aliases
Thoughts?
Comment #4
Jon PughMarking for 6.x-1.x-dev for now.
Comment #5
anarcat CreditAttribution: anarcat commentedPlease mark patched issues as needs review!
Comment #6
anarcat CreditAttribution: anarcat commentedI like this. The interface is better and is a good way to move forward towards #815190: Allow for both redirects and aliases.. We'd just need a "redirect" flag per alias then...
Please port to 2.x, this will not land in 1.x. Thanks for the great work!
Comment #7
helmo CreditAttribution: helmo commentedI've spent some time on this. Testen on 6.x-2.x
* style clean up
It needs more attention, but here's an intermediate result as I'm out of time today.
Comment #8
anarcat CreditAttribution: anarcat commentedPushed as 191766c, thanks.
Comment #9
omega8cc CreditAttribution: omega8cc commentedWhen "Generate www.domain.com alias automatically" and "Generate domain.com alias automatically" options are enabled, and the main site name is foo.com, it allows you to choose www.foo.com as a "Redirection Target", while in fact in the vhost foo.com is the target still.
Comment #10
Steven Jones CreditAttribution: Steven Jones commentedThere's another serious issue with what's been committed here too. The update functions depend on the hook_schema implementation so the update functions are not fixed. We need to pull the portion of the hook_schema we want out, and put in the update function.
Comment #11
ergonlogicAlso, isn't the convention to call the function something like hosting_alias_update_620x() ?
Comment #12
helmo CreditAttribution: helmo commented@Steven Jones: the patch here fixes that.
@ergonlogic: Yes that's the convention, but the older update hooks in that file had the same bad pattern. However I think we should still start doing it right from here one.
I'm not sure about the Nginx part, but it seems that we 'lost' the provision part of this patch. Here's a reroll.
The http/Provision/Config/Nginx/vhost.tpl.php core seems to only do redirects when $ssl_redirection is true.
Comment #13
anarcat CreditAttribution: anarcat commentedlet's see if those patches finish this off properly - my bad for both missing the provision patch and the weird schema anti-pattern.
thanks for the reroll helmo.
edit: sorry - i forgot to give attribution...
Comment #14
omega8cc CreditAttribution: omega8cc commentedThis needs to be fixed also for Nginx config.
Comment #15
anarcat CreditAttribution: anarcat commentedAh right, sorry I missed that. :)
Comment #16
helmo CreditAttribution: helmo commentedI saw a notice as the result of the redirect code.... fixed in http://drupalcode.org/project/hostmaster.git/commit/46e3498
Comment #17
anarcat CreditAttribution: anarcat commentedgood. anyone working on a fix for nginx though?
Comment #18
anarcat CreditAttribution: anarcat commentedi fixed it for nginx. we have found that there are weird checks in the code for apache which ergonlogic will remove and detail some more, so I am keeping this open for now.
Comment #19
anarcat CreditAttribution: anarcat commentedactually, scratch that, it still doesn't work. graah.
Comment #20
anarcat CreditAttribution: anarcat commentedokay, now this is done.
Comment #22
helmo CreditAttribution: helmo commentedFor reference, I've posted a small follow-up: #2010064: Extra update hook to fix hosting_site_alias table content
Comment #22.0
helmo CreditAttribution: helmo commentedUpdated issue summary.