I store the directory path in a variable and use it also to create the directory if it doesn't exist:
(defvar --undo-history-directory (concat user-emacs-directory "undos/")
"Directory to save undo history files.")
(unless (file-exists-p --undo-history-directory)
(make-directory --undo-history-directory t))
;; stop littering with *.~undo-tree~ files everywhere
(setq undo-tree-history-directory-alist `(("." . ,--undo-history-directory)))
While this was inspired from the other answers, I'm putting it here since I stumbled around the quoting since --undo-history-directory
is a variable and not a string literal.
For those interested, we're using the backquote construct to selectively evaluate elements in a list.