diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py
index 9af122c..dd3eef4 100644
--- a/IPython/frontend/html/notebook/handlers.py
+++ b/IPython/frontend/html/notebook/handlers.py
@@ -609,6 +609,20 @@ class ShellHandler(AuthenticatedZMQStreamHandler):
# Notebook web service handlers
#-----------------------------------------------------------------------------
+class NotebookRedirectHandler(AuthenticatedHandler):
+
+ @authenticate_unless_readonly
+ def get(self, notebook_name):
+ app = self.application
+ # strip trailing .ipynb:
+ notebook_name = os.path.splitext(notebook_name)[0]
+ notebook_id = app.notebook_manager.rev_mapping.get(notebook_name, '')
+ if notebook_id:
+ url = self.settings.get('base_project_url', '/') + notebook_id
+ return self.redirect(url)
+ else:
+ raise HTTPError(404)
+
class NotebookRootHandler(AuthenticatedHandler):
@authenticate_unless_readonly
diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py
index 86d48fd..c7fac6b 100644
--- a/IPython/frontend/html/notebook/notebookapp.py
+++ b/IPython/frontend/html/notebook/notebookapp.py
@@ -52,7 +52,7 @@ from .handlers import (LoginHandler, LogoutHandler,
ShellHandler, NotebookRootHandler, NotebookHandler, NotebookCopyHandler,
RSTHandler, AuthenticatedFileHandler, PrintNotebookHandler,
MainClusterHandler, ClusterProfileHandler, ClusterActionHandler,
- FileFindHandler,
+ FileFindHandler, NotebookRedirectHandler,
)
from .nbmanager import NotebookManager
from .filenbmanager import FileNotebookManager
@@ -86,6 +86,7 @@ from IPython.utils.path import filefind
_kernel_id_regex = r"(?P\w+-\w+-\w+-\w+-\w+)"
_kernel_action_regex = r"(?Prestart|interrupt)"
_notebook_id_regex = r"(?P\w+-\w+-\w+-\w+-\w+)"
+_notebook_name_regex = r"(?P.+\.ipynb)"
_profile_regex = r"(?P[^\/]+)" # there is almost no text that is invalid
_cluster_action_regex = r"(?Pstart|stop)"
@@ -136,6 +137,7 @@ class NotebookWebApplication(web.Application):
(r"/logout", LogoutHandler),
(r"/new", NewHandler),
(r"/%s" % _notebook_id_regex, NamedNotebookHandler),
+ (r"/%s" % _notebook_name_regex, NotebookRedirectHandler),
(r"/%s/copy" % _notebook_id_regex, NotebookCopyHandler),
(r"/%s/print" % _notebook_id_regex, PrintNotebookHandler),
(r"/kernels", MainKernelHandler),
@@ -170,6 +172,7 @@ class NotebookWebApplication(web.Application):
cookie_secret=os.urandom(1024),
login_url=url_path_join(base_project_url,'/login'),
cookie_name='username-%s' % uuid.uuid4(),
+ base_project_url = base_project_url,
)
# allow custom overrides for the tornado web app.