New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds modrewrite functionality (SPA HTML5 location history) #86
Comments
I'm not familiar with modrewrite. What would that do? Also what is that regexp, anything ending in a slash, at the end of a string? What's the [L] WSC does not use configuration files, the interface to configure options is just checkboxes... |
Add a new checkbox for html5Mode on. And if the entry does not exist redirect to the index.html.
|
This functionality is required for running many of the Polymer SPAs, I think those projects would benefit greatly by Chrome Web Server but it would require this option. |
Fascinating. So in this mode, every URL simply goes to the /index.html at the root? Server side from: https://docs.angularjs.org/guide/$location#html5-mode Note that angular docs themselves seem not to use modrewrite :-) |
@kzahel I'm not that familiar with angular but the two major ways of handling SPA routing are the hashbang or a server rewrite. The hashbang method requires URLs to be transformed and ugly, from your link you can see the example Alternately, you configure the server to pass all extensionless requests to @ajsb85 showed how to do it on a node server
A web.config file example would be:
I'm not sure how easy it would be to implement in this project (which I love! and by the way THANKS!). But it'd be a useful feature for SPA development. Edit: I should also mention I'm like 97% sure this is what @thevukaslt is trying to do in issue #89 |
@cgriffin4 thanks for the detailed info. This means any request for any asset matching the regexp will not actually look for a file on the disk with that path, but instead index.html With your example ".*.[\d\w]+$" regexp, what does this try to match? I'm guessing there are a lot of regexps people would use, but wouldn't most people exclude something like a "/static/" "/public/" or "/assets" folder? |
@kzahel You could handle it by having directories to exclude like you mention with "/static", etc but I usually just assume if it doesn't have an extension then it's requesting a location on the site (so serve the site, which is just Currently (with auto index.html turned on): The desired option would be that when serving |
@cgriffin4 with your example (any url with a dot is not rewritten) |
Sorry, worded that poorly. I have not used connect-modrewrite myself and was wondering if var app = connect() Would first try to find the static files before using the modRewrite (which redirects all back to index.html I believe?)? Ill setup a test I guess to figure that out |
@kzahel The idea is to keep the request completely. Basically, the easiest way to think of it is an alternative to "Automatically show index.html". This is simply "Automatically show /index.html". So the url isn't redirected, altered, or destroyed. Right now we have the choice of displaying a directory contents, or displaying the index.html file in a directory. While this is great, it's arguably more common that you'd want to display a single index.html file instead of having a site with multiple index.html files. So this would mean that when browsing to a directory (or non-existent directory) there would be an option that would load a global index.html (commonly located in the root, thus In fact, if the code was easier and you didn't want to add another option then @bbarrows I'm not sure about the regex but what I usually do is allow for |
@kzahel I wouldn't suggest using this hack directly as it's hacky but it's an example of a simple solution which shouldn't break many other use cases. If you put the following line in the file
So if the entry was not found in the filesystem and the option to show index.html is true and the path requested does NOT have an extension (could possibly simplify that regex) then default to the root directory (which will then default to showing the index.html in the root directory). Tested it on the Polymer News PWA and it loads fine with that change. It does mean someone could expect to get a 404 if they wanted to load |
I added an option to a new branch. I haven't tested it much, maybe you could help The branch is modrewrite. You'll probably have to go to polymer-ui folder and run bower update and run build.sh to update the frontend (now using tooltips) |
This is now in the current live version. I haven't received any feedback though if it's working. |
I will test it |
Working fine, the only problem is that the response is not including the content-type, thus the browser doesn't know it's an html page. 127.0.0.1:8887/hello serves /index.html, but as a text file. |
that's a good point -- i should default to serving as content type html if
content type cannot be determined from file extension when mod-rewrite is
on.
…On Fri, Nov 17, 2017 at 5:39 PM, Rafael Perrella ***@***.***> wrote:
Working fine, the only problem is that the response is not including the
content-type, thus the browser doesn't know it's an html page.
127.0.0.1:8887/hello serves /index.html, but as a text file.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#86 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJqkNu3rbYkdcNC8BIU8YPhdE1MdZOFks5s3jVUgaJpZM4LHoR->
.
|
@kzahel should this be closed? |
Hi @kzahel
I want this feature.
To support
$locationProvider.html5Mode(true);
The text was updated successfully, but these errors were encountered: