camme / jquery-router-plugin

Jquery plugin to handle routes for both hash and push state.
104 stars 47 forks source link

[support] configuring the web server #13

Closed ambs closed 7 years ago

ambs commented 7 years ago

Sorry for posting here for support, but seemed like the best place to do so. Given the minimum documentation (that is good!), I got a little confused.

While working with hashtags seems easy to understand how will be handled by the webserver, how the redirects with full 'URL paths' will work? The server will not find a page "there"...

So, there is some detail that is missing in my head to understand the mechanic it will use. And any hint is quite welcome.

As a side question: will it handle relative URLs?

ambs commented 7 years ago

The website is starting to look great (http://novo.dicionario-aberto.net/ -- just working the random icon, first in the toolbar). The problem is that when I use directly the '/random/ URL, it will not work. (apache here)

Hints are welcome.

ambs commented 7 years ago

Curious. Added this to my apache configuration file:


  RewriteEngine On
  # If an existing asset or directory is requested go to it as it is
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
  RewriteRule ^ - [L]

  # If the requested resource doesn't exist, use index.html
  RewriteRule ^ /index.html

Now, if I visit 'http://novo.dicionario-aberto.net' or 'http://novo.dicionario-aberto.net/random' no routes get triggered. Other URLs fails with a 404 (OK) unless they end in a slash (Not OK)

ambs commented 7 years ago

OK, after that configuration, make sure to call $.router.check(); after defining all routes, in order to redirect to work (please add this to the readme).

Now, just need to check why when adding a nonexistent route that includes a slash, the redirect doesn't work properly.

ambs commented 7 years ago

It was my HTML fault, that did not include the starting slash when including the JS and CSS.

dihar commented 7 years ago

ambs, author of this repository doesn't answer. I forked this project and used in my "pseudo" framework. You can see fork here https://github.com/camme/jquery-router-plugin/pull/11 , and project here https://github.com/dihar/fast-framework , https://github.com/dihar/fast-framework-core . What about config, I don't know, how it to do on the apache. All requests must give index.html , where router plugin will process URL . In nginx this config named "tryfile".

ambs commented 7 years ago

Yeah, I noticed. but solved for now. Thanks.