I have an existing Jetty web app project where the webapps folder is set up like this:
webapps
|
| root
|
| icons
|
| a.jpg
and I can access a.jpg by accessing this URL:
http://localhost/icons/a.jpg
I guess that's the default root folder in Jetty where it can serve static contents? Since I can't find any reference to the "root" folder in any configuration file.
I would like to dynamically change the location of this "root" folder so that I can, say, do this (pseudocode)
setRoot("C:/myNewRoot/icons")
and when I go to http://localhost/icons/a.jpg, it would serve C:/myNewRoot/icons/a.jpg instead of webapps/root/icons/a.jpg
I'm guessing this will involve some sort of servlet and servlet-mapping that would handle /icons/*, but I can't figure out how.
Is this possible?
You cannot change the base resource of a WebApp / War file, without breaking everything else that the WebApp depends on.
As for the meaning of "root" and "ROOT" as a deployable name ...
https://www.eclipse.org/jetty/documentation/current/automatic-webapp-deployment.html
https://www.eclipse.org/jetty/documentation/current/configuring-contexts.html#usng-the-context-provider
Related
I want to deploy a new Symfony 4 project (the symfony-demo) from local to a IIS web server. The project should stay in its own sub directory. The IIS webroot is two levels higher. When I go to public/index.php of my project (which is releative to the webroot in /sf/symfony-demo/), the templates are not shown correctly, since the server does not find the correct JavaScript directory in build/js/...), see screenshot
I call http://192.168.1.203/sf/symfony-demo/public/index.php, but fails to load from http://192.168.1.203/build/manifest.js.
On the server, I can not set the webroot or create virtual directores. Also, I have no command line. I need to do it via configuration in symfony or a correct write/rewrite rule in web.config file.
How can I set the sf- project root directory relative to the IIS webroot, in my case to /sf/symfony-demo/public ?
Can somebody provide a rewrite rule in web.config in /sf/symfony-demo/ or in /sf/symfony-demo/public? Or do I need to set the directory somewhere (prefix? asset?) in my project configuration files (e.g. \sf\symfony-demo\config\packages\framework.yml)?
Edit
I got it working somehow, there is a similar discussion and a solution for a symfony 2 project:
Symfony 2 project in nested directory
by adding in symfony-demo\config\packages\framework.yaml a line at assets :
base_urls:
- 'http://192.168.1.203/sf/symfony-demo/public/'
But somehow this looks strange for me to set the path this way. Setting here
base_path: '/sf/symfony-demo/public/'
does not work. I would expect to set the (relative) path explicitly somewhere, not a url. But where?
Also, setting extra.symfony-public-dir in composer.json like in
http://symfony.com/doc/current/configuration/override_dir_structure.html
does not work.
Regarding the rewrite rules:
Yes I read the doc, but I found nothing for web.config on iis for symfony on
https://symfony.com/doc/current/setup/web_server_configuration.html.
But I found a iis web.config for silex
[https://silex.symfony.com/doc/2.0/web_servers.html .
It looks like the web.config is not the real problem here.
Thank you for taking the time to read this. d.
I deployed my app in example.com/app but all my routes are broken.
Oops, looks like there's no route on the client or the server for url: "http://example.com/app/."
I can try to manually prepend to all routes /app/ subfolder but it doens't seem the right approach, especially since i use a cms package (orionjs) to generate the /admin interface, which doesn't have support to change the admin path.
Is there any way to prepend the /app folder to all routes by default?
What i find strange is that i defined ROOT_URL to http://example.com/app/ but iron router seems to ignore it. Did i skip a step ?
Unlike many web platforms (ex: php), the folder structure under your app does not map automatically to routes. If you're using iron-router you basically define what layout maps to what route. The layout can be defined in an HTML file in any folder (except under /server or /public) at any depth. You can also add any extra depth you want to any route in iron-router by prepending app/ or whatever you want to your route definitions. Your ROOT_URL should remain http://example.com/
I want to know the root of the application both system eg. /var/www/app/ or /app/ for the purposes of file uploads. When I upload, I believe I need the "system" directory name, for use to links in web front end, I need the "relative" path. How do I get this information?
In a previous project, I defined constants in the app*.php files (front controller)
define('APP_ROOT', __DIR__);
Wonder if theres a better way?
In any ContainerAware class you can get location of web directory by,
$this->container->get('kernel')->getRootdir().'/../web';
If the container is not available, you can use dependency injection: set %kernel.root_dir% as an argument to your class in the service configuration.
What are the differences between ./, ../, and ~/ for specifying an image in my web application?
Like current directory, root, parent directory, etc.
"./" //the current directory
"../" //the parent directory
"/" //the site root directory
"~/" //virtual root Web path
ASP.NET Web Project Paths is a very good article in MSDN regarding paths in ASP.NET with good examples.
Web Pathing:
./ means this folder, equivalent to nothing on the front
ex: ./image.jpg and image.jpg are the same thing
/ the web application root folder
ex: /Test/image.jpg, go to the application root, find folder Test, find image.jpg
../ means up one folder then go to the folder after the slash...
ex: ../Test/image.jpg, go up one folder from the current folder your in, go into folder Test, and find image.jpg.
Physical Pathing:
~/ means the application physical root folder. This will not work if you are using it directly in the webpage (ex: <img src="~/images/image.jpg" />). You can use ResolveUrl to get the web path to a file. I have used this for referencing JavaScript libraries in a master page. I've also seen it used in some custom uploaders.
We have an application that is making use of the location tag in the web.config file at the machine level - meaning like C:\Windows\Microsoft.NET\Framework\v2.0...\CONFIG\web.config, the one that applies to the whole server - this application has lots of virtual directories under it and for each one there is a
<location path="IIS Web App Name\CustomerA">...
This seems to work ok for that app. But then we have a second app on the same server, and I'd like to add location tags to that app's web.config file - meaning the local web.config file in the app's directory - and have each one of them specify a location tag in a similar way.
Is this possible? Because it doesn't seem to work. I've tried:
<location path="My IIS App Name\CustomerA"> ...
and
<location path="CustomerA"> ...
and neither seem to work. I just need this location node to contain 1 node.
Is there maybe some
It would have to be a file or folder within that virtual. So I could set rules for "default.aspx" in the same root as the config file, or manage a folder like "Content" for the Content folder. I've done this successfully.
Or, put another config file in the folder you want to set custom rules for, and define rules there that will override the main...
HTH.