I wrote a simple mvc framework. The configured route is very simple, such as modulecontrolleraction. When accessing localhost: 86appindexindex, you can render the view file. The problem arises. Access the page through a route such as appindexindex and write a simple mvc framework on the page. The configured route is very easy to use rules such as module/controller/action.
When accessing localhost: 86/app/index, you can render the view file.
The problem arises.
Access the page through a route such as app/index, and write a jump
Click to jump to the page
In this case, the browser browsing path may change to localhost: 86/app/index/demo/index.
But sometimes it can be accessed normally and changed to localhost: 86/demo/index.
Two differences are found: app/index and/app/index in href. Is there any way to better solve this routing problem?
Project source code in https://github.com/zhoujiangy ....
Reply content:
I wrote a simple mvc framework. The configured route is very easy to use rules such as module/controller/action.
When accessing localhost: 86/app/index, you can render the view file.
The problem arises.
Access the page through a route such as app/index, and write a jump
Click to jump to the page
In this case, the browser browsing path may change to localhost: 86/app/index/demo/index.
But sometimes it can be accessed normally and changed to localhost: 86/demo/index.
Two differences are found: app/index and/app/index in href. Is there any way to better solve this routing problem?
Project source code in https://github.com/zhoujiangy ....
This is the URL path problem. it has nothing to do with your route.
App/index is the relative path.
/App/index is the absolute path.
Similar to the file system path, for example:
If the current location is/a/B/c
So,
Href = "foo/bar" to jump to/a/B/foo/bar
Href = "/foo/bar" to jump to/foo/bar.
This is not determined by your framework routing, but by web standards.
Href = "/xxx" is different from href = "xxx/xxx ".