I'm not sure that this expresses the intended behaviour that clearly. What about:
```ruby
if hostname.start_with?('www.')
  hostname.sub(/^www./, 'aka.')
else
  'aka-' + hostname
end
```