Discussion:
[Wt-interest] Clean URLs
Rutger ter Borg
2016-05-26 21:00:46 UTC
Permalink
Hey all,

I'm running a Wt application through wthttpd. It's deployed at '/'. In
order to get clean URLs, I configured --docroot to also list the
directories of static content.

This works, Wt is deployed at '/'. All URLs are clean, except for the
one referring to the site's root. So, generated hrefs from an
InternalPath set to '/' shows up as '/?'.

domain.com/?
domain.com/about
domain.com/login
domain.com/the/rest/is/clean

Is there an additional configuration option I might have overlooked?

Thanks,

Rutger
K. Frank
2016-05-26 21:34:42 UTC
Permalink
Hi Rutger!

I don't have an answer to your question, but rather, some
questions of my own.
Post by Rutger ter Borg
Hey all,
I'm running a Wt application through wthttpd. It's deployed at '/'. In
order to get clean URLs, I configured --docroot to also list the
directories of static content.
This works, Wt is deployed at '/'. All URLs are clean, except for the
one referring to the site's root. So, generated hrefs from an
InternalPath set to '/' shows up as '/?'.
domain.com/?
domain.com/about
domain.com/login
domain.com/the/rest/is/clean
I am still uncertain how static content, URLs, InternalPath, and
--docroot all work together.

For starters, could you tell me the exact command line you use to
launch wthttpd (censored of any sensitive information, of course)?

Also, what system are you running on. (I am using Wt on windows 7.)

When you say static content, do you mean ordinary html files (that
could be served by something other than wthttpd, if you so chose)?

So, let's say you launch your wthttpd application (in windows notation)
from:

C:\somelaunchdirectory

Does this mean you have subdirectories

C:\somelaunchdirectory\about
C:\somelaunchdirectory\login
C:\somelaunchdirectory\the\rest\is\clean

and you list these directories in your --docroot command-line
argument? Do these three directories then each contain an index.html
file?

I've played around with this some myself, but I haven't been able
to get --docroot to work the way I "expect" (but there is no reason
to think that my expectations are correct).
Post by Rutger ter Borg
Is there an additional configuration option I might have overlooked?
(Sorry, I don't have an answer.)
Post by Rutger ter Borg
Thanks,
Rutger
Thanks for any insight.


K. Frank
Rutger ter Borg
2016-05-27 07:38:44 UTC
Permalink
Post by K. Frank
I am still uncertain how static content, URLs, InternalPath, and
--docroot all work together.
It's quite straightforward, there's

approot: this is where your application runs, so if you open files from
within your app, this is where to look. E.g., xml content files are
usually found here.

docroot: if your wt-app serves static files, they are served from this
directory. But you have to tell the application which directories are
used for this. By default, this is everything in the resources
directory. --docroot=/place/to/static/content;/resources,more statics...

A Wt application may run at 'domain.com/', but may also run at
'domain.com/heres/wt'. This is the deployment path of Wt.

An internal path of Wt is whatever is beyond the deployment path.

A URL is the full combination of scheme, hostname, and path (and maybe
some parameters).
Post by K. Frank
For starters, could you tell me the exact command line you use to
launch wthttpd (censored of any sensitive information, of course)?
For development, I'm using

approot = /path/to/source_tree/approot
docroot = /path/to/source_tree/docroot;/static
http-address = 0.0.0.0
http-port = 7654
Post by K. Frank
Also, what system are you running on. (I am using Wt on windows 7.)
currently, I'm running Debian/Ubuntu.
Post by K. Frank
When you say static content, do you mean ordinary html files (that
could be served by something other than wthttpd, if you so chose)?
See above. Usually this is non-html content, although it could indeed
include static html. For static html content, I would recommend using a
WMessageResourceBundle.
Post by K. Frank
So, let's say you launch your wthttpd application (in windows notation)
C:\somelaunchdirectory
As you word it, this would be your approot.
Post by K. Frank
Does this mean you have subdirectories
C:\somelaunchdirectory\about
C:\somelaunchdirectory\login
C:\somelaunchdirectory\the\rest\is\clean
and you list these directories in your --docroot command-line
argument? Do these three directories then each contain an index.html
file?
I have something like

...\docroot\static\css\...
...\docroot\static\js\...
...\docroot\static\img\...
...\docroot\static\font\...

but my mapping of the internal-path (e.g., /about) to a part of the wt
application is not related to a file structure.

HtH,
Cheers,

Rutger
Koen Deforche
2016-05-27 10:28:21 UTC
Permalink
Hey Frank,
Post by K. Frank
Post by Rutger ter Borg
Hey all,
I'm running a Wt application through wthttpd. It's deployed at '/'. In
order to get clean URLs, I configured --docroot to also list the
directories of static content.
This works, Wt is deployed at '/'. All URLs are clean, except for the
one referring to the site's root. So, generated hrefs from an
InternalPath set to '/' shows up as '/?'.
domain.com/?
domain.com/about
domain.com/login
domain.com/the/rest/is/clean
We cannot reproduce the '/?' issue. Can you reproduce this misbehaviour in
a small test case?
For example, on the wt homepage, this works: the languages menu has a link
to internal path '/' for the English language.
Post by K. Frank
I am still uncertain how static content, URLs, InternalPath, and
--docroot all work together.
It's confusing, for sure, but let me try to explain in summary:

1) static content are files which are offered verbatim, by a web server, to
a web browser, by translating an incoming request URL to a file on the file
system. When deploying with wthttpd, the translation is done by considering
the --docroot. The docroot is the folder which contains your static
contents, and Wt will translate an incoming request of
http://myserver.com/this/url/file.txt to a file on the system within the
docroot folder: {docroot}/this/url/file.txt

2) an application is deployed at a certain URL, e.g. the Wt homepage is
deployed at '/wt' inside http://www.webtoolkit.eu/. URLs within the '/wt'
are also handled by this application. For example
http://www.webtoolkit.eu/wt/blog is handled by this application, and the
corresponding internal path is '/blog'.

There is one particular problem which leads to 'ugly URLs', namely if you
deploy your application at '/', i.e. the root of your server. Then Wt
cannot decide which URLs should be considered a request for a static file,
or a request for an internal path inside your application. To avoid
misbehavior, Wt resolves this by using a different syntax for 'internal
paths' in this case: /?_=/internal/path instead of /internal/path, leaving
all other requests to be for static files. This can be solved by indicating
to the web server specifically which URLs should be considered as static
file request: --docroot='.;/css,/html,/resources'. With this specification,
a request for http://mywebserver.com/css will be handled as a static file
request, served from within the docroot, while any other URL not listed,
like http://mywebserver.com/some/path, will be handled by your application.

Koen
Rutger ter Borg
2016-05-27 12:24:43 UTC
Permalink
Post by Koen Deforche
We cannot reproduce the '/?' issue. Can you reproduce this misbehaviour
in a small test case?
Hey Koen,

please find attached a minimal testcase. I'm seeing the same behaviour
for WMenuItems (not in this testcase).

Cheers,

Rutger

Loading...