How to set a subfolder as webapp root on Azure Linux - linux

I'm using Linux on Azure to host my webapp and it deploys fine. My local dev tree structure looks like this:
build
node_modules
src
.deployment
.env
.gitignore
package.json
README.json
...
When I deploy to Azure it looks like this:
dist
node_modules
Within one of my files I re-utilize some components from a node module like so:
import Password from '../../../node_modules/path/to/components/forms/field-types/Password';
There are 2 potential ways to make this work:
Deploy /dist into the root and have node_modules as a sibling but this then makes the relative path above break and ES6 doesn't allow dynamic import strings nor for them to be within blocks
Set the /dist folder as the application root which is actually correct (eg: it contains server.js) and then the relative paths would be correct
I'd prefer #2 however the capability for doing virtual path mapping in Azure doesn't seem to exist so it seems I'd need to leverage .htaccess. I'm curious if there are any other ways to do this and also if the root is set to /dist will the relative path still work or will it be blocked by the server?
Thanks.

.htaccess file setting **RewriteEngine On** on the request path. So if you add an admin-specific .htaccess file in the "subfolder" subfolder, this will preempt the www one and circumvent this problem.
EX:
RedirectMatch ^/my_folder/(.+)/card.jpg$ /script_folder/image.php?perameter=$1
This willredirect /my_folder/xyz/card.jpg to /script_folder/image.php?perameter=xyz changing the address bar from typed url to a new url. If you want the browser to stay on the typed url, you can use the following mod rewrite based solution :
RewriteEngine on
RewriteRule ^my_folder/(.+)/card.jpg$ /script_folder/image.php?perameter=$1 [L]
Please refer this DOC:
Deploy files to App Service - Azure App Service | Microsoft Learn

Related

.htaccess load from sub folder but keep on showing main domain

I have a install that has a web folder that has the website stored in this. How can I make the domain load from this folder within the public_html folder.
The domain is like: sub.domain.co.nz
Don't put the entire Symfony project under the public_html folder - this will cause all of the project files to be accessible over the web, including .yml files that include sensitive information like database passwords!
Put the Symfony project files in a folder that is not web accessible. Then configure your web server so that the DocumentRoot points to the path of the web folder of the Symfony project, and also modify the paths of all the aliases.

Laravel: routing multiple websites to one Laravel app folder in shared hosting, different routes

I have no idea how to do this, and I have to use this hosting option.
I have a public_html dir in my home, this folder has a website in it already.
Then inside the public_html there is a symlink to my laravel folder, let's call it laravel. So whenever I go to myhost.com/laravel it works, I get the laravel app. The route inside the app for this is /.
What I would like to do now is make another symlink in public_html, point it to the same laravel app, but use a different route. So for example, I create a symlink app2 to the laravel folder but hit a different route than /.
Is this possible? I have no sudo access, no vhosts configuration.
I'm guessing it could be possible with .htaccess rewriting sorcery, but I have no knowledge on where to even start.
Thank you.
Ok, so besides being downvoted without criticism, I solved my problem. Here is how:
I had to add a prefix to my urls, so a.com/x became a.com/apps/x.
Added a symlink to the laravel public folder in the public_html called apps. Then added routes x and y to laravel.
Created folders x and y inside public_html and, inside these folders, made a always redirect .htaccess to the related route:
RewriteEngine on
RewriteRule ^(.*)$ http://a.com/apps/x [R=301,L]
So whenever I access a.com/x I get redirected to a.com/apps/x.

moodle data root location not secure error

I read moodles documentation where it says that if the data root directory has to be in the site's public html folder ( Please see that i can not create it outside it since i dont have sufficient privileges as i am using a free account ). then you have to chmod it to 770 and also use htaccess to protect it.
Now i am creating the moodle inside my domain at folder /moodle/
and moodle uploads folder is /moodle-uploads/uploads/
and i have an .htaccess setup in /moodle-uploads/.htaccess
where its contents are
order deny,allow
deny from all
as specified on
http://docs.moodle.org/20/en/Creating_Moodle_site_data_directory
But still when i run the auto installer script it says the data root directory is not secure
This is not the best way of doing it but coding hack to just get rid of this error if you like try it..,
in moodle root go the install.php and if you are using 2.6 in line 341 or others versions search for is_dataroot_insecure() function and change it to false in the else if condition and try to install again,and that it..,
By default its going to give you warning for having it in the public html folder as according to the docs in the link you also provided.
Remember that by default moodle will issue a warning about moodle data
directories created inside the web directory, but otherwise this
directory can be located where you wish. You can later move or change
the location of this directory, but if you do, be sure to edit the
setting in the config.php file that sets this; e.g. if moodledata is
under a directory called data, then it would look like this:
As long as you have configured the dataroot location with the moodle data directory and placed your .htaccess file in that folder it should be fine.
i'm using moodle 2.4.1 and had a some problem. the solution open install.php file and search for statment
} else if (is_dataroot_insecure()) {
and disabled.
it's work for me

Twig templates directory

I'm new to Twig and was wondering where I should place the Twig /templates directory.
I'm using composer and placing the /templates in the root directory where the index.php is and it gives me the following error message :
Message: The "/templates" directory does not exist.
File: /home/teo/SERVER/public_html/JSON_FOLDER/JSON2/vendor/twig/twig/lib/Twig/Loader/Filesystem.php
Generally you put it anywhere not within your web root, that's the best practice. But if you have no access anywhere else, then the web root will have to do.
I'm not completely familiar with composer, but you'll probably want to specify a path that is relative to your web directory instead of an absolute directory like you've done already. That error shows that its trying to find a templates path in your server ROOT directory which is almost never going to be where you actually want it. Try just removing the leading slash in your config.

yii, Development and URL issues

We have our server which runs the site at 173......54/
For development we want to have a copy of the code that can be tested at 173.....54/~me/site
When I install a copy of Yii and the code at ~me/ folder and access 173.....54/~me/site I am able
to see the newly installed index html. However, if I try to move to 173.....54/~me/site/book or a user register page or any other page the other (main) Yii application reads the code as a link not found instead of the development Yii application.
Am I supposed to update a the htaccess file to ignore requests within /~me ? If so how should it look? Or am I missing something?
Thanks again!
No need to make ignore in other .htaccess, the dev site .htaccess will take care of it.
In your index.php at the root of your dev site you need to point $yii at your Yii framework/yii.php
and then in the .htaccess in the root of your dev site you need to point RewriteBase to your dev site root.
Also make sure you point to the correct configuration file corresponding with your application in index.php

Resources