Skip to content

How to set the default route #30

Closed Answered by rehhouari
docdunning asked this question in Q&A
Discussion options

You must be logged in to vote

I think the best approach would be not have index.html in the URL at all. That's not how client side routers are meant to work.
Take this for example: https://reactrouter.com/index.html
It also shows 404. And it's the most used framework and router, so it's the standard.
and no you can't use regex only options are mentioned in the README.

/index.html is inconsitant cause then shouldn't the rest of the routes be /index.html/about or even /about.html?

However if you're forced to use it, this may be a better approach:

<template x-route="/index.html" x-handler="ctx => ctx.redirect('/')"></template>

This will make it so it only redirect to / when you view /index.html route.
Your method in x-init

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by rehhouari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants