Azure Web App - Linux/Laravel : Point domain to folder - azure

I just started using Azure and created a Linux web app.
I followed the domain DNS tutorial and setup my domain :
https://learn.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-custom-domain
I used the custom domain - text type
test.com does not point to the folder /site/wwwroot on the app.
I placed the site folder in /wwwroot
However, in laravel - the actual site is in /sitefolder/public
How do I point to this folder?
Thanks

It has nothing to do with DNS. What you need to do is create a .htaccess file containing the following code and place this file in Laravel's root directory.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
More on this:
How can I remove "public/index.php" in the url generated laravel?
Apache rewrite for Laravel /public

Related

How to redirect non www to www for prod website

I've tried to add the item below in .htaccess(wamp64\bin\apache\apache2.4.37\conf) and enabled Use URL Rewriting in Joomla however when I try to type abc.com in search engine address bar it will still redirect me to search page instead of redirecting me to the website. I've also performed checking and confirmed that .htaccess file is readable, the webpage is work when go to https://www.abc.co m however redirection still not work. I just need the page to redirect from http://abc.co m to https://www.abc.co m Is there any other way to do it? Or I'm doing it wrongly?? Please help.
RewriteCond %{HTTP_HOST} ^abc.com [NC]
RewriteRule ^(.*)$ https://www.abc.co m/$1 [L,R=301]
The redirect itself works great. The issue is where you've put the file.
.htaccess files are meant to be in the root folder and sub-directories of your website, not in the config files for Apache. Think of them as configuration files the server will find on-the-fly as it serves up documents, not static configurations loaded when the server starts (which are found in the "conf" folder you referred to). (See https://httpd.apache.org/docs/current/howto/htaccess.html)
For WAMP, the root folder is typically a folder called "www" and is normally located at c:/wamp/www. See Where is the web server root directory in WAMP? More commonly, though, this folder is called "public_html" (such as with LAMP, XAMP, MAMP, or default Apache installs).

Symfony 3.4 located in subdirecory, remove web/ from url

I have 3 php apps on one server. I cant modify any apache files. Haw can I set .htaccess to remove web/ folder from url?
192.168.45.54/app1/
192.168.45.54/app2/
192.168.45.54/app3/web - I want to change it to 192.168.45.54/app3/
On adress 192.168.45.54/app3/web/ everythink is working fine. But haw can I remove web/ from url?
I created .htaccess files:
RewriteEngine On
RewriteBase /app3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ web/$1 [QSA,L]
But when I go to 192.168.45.54/app3/ in symfony log files I have fallowing error:
No route found for "GET /app3/"
I use Symfony in 3.4 version. I think that problem is in .htaccess located in /web directory... Haw to configure .htaccess corectly?
I can't create virtual host becouse I haven't access to the server...
You need to make the web/ directory the document root of your website. If you have direct access to the webserver’s virtual host configuration, change the document root to the following line and restart Apache:
DocumentRoot /path/to/symfony/web/
If you can’t modify the virtual host file directly, your hosting provider will usually give you the possibility to modify the document root through some kind of online tool.

.htaccess: hiding subdomain with proxy redirect / rewrite

I need to access my site that sits in a subfolder from my domain.
The challenge - Due to my hosting structure, all sites are on the master domain's server in subfolders. Domains are mapped to those folders for each site. The master domain, however, is mapped to the server root like this -
• /www/ (root of www.masterdomain.com)
/folder 1/ (root of www.site1.com)
/folder 2/ (root of www.site2.com)
/folder 3/ (root of www.site3.com)
/folder 4/ (desired root of master domain)
If i install my CMS in folder 4 everything is fine, BUT the CMS code creates new assets in the server root (using DOCUMENT_ROOT i think), NOT in the subfolder.
Attempted fix 1:
Use a rewrite to remove subfolder and set all paths to include subfolder.
Failed - CMS acts as desired, but assets still created in the root.
Attempted fix 2:
Map a subdomain to the folder and rewrite URL to remove subdomain.
Failed: CMS works on subdomain and creates assets in the subfolder (win!), but can't rewrite a subdomain.
Attempted fix 3:
Map a subdomain to the folder, and use a proxy flag from the main domain to load content from it invisibly.
Progress made! Main homepage displays with the correct URL, however linked files and subfolders do not work.
So i can now reach my web app from:
app.exampledomain.com (app works perfectly on all fronts)
OR
exampledomain.com (proxy in effect, all subfolders and links broken)
Here's my htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Proxy subfolders
RewriteRule ^exampledomain.com/(.+?)?$ http://app.exampledomain.com/$1 [P,L,NC]
# Proxy main
RewriteRule ^(exampledomain.com)?$ http://app.exampledomain.com/ [P,L,NC]
So why are my subfolders / assets not working? Problem with the .htaccess? Bad logic?
Important notes -
Subfolder pages are called index.php so can be accessed from -
/folder/
The broken links on the page are in this format -
js/foundation.min.js
Thanks.
RewriteRule knows nothing about domain names, it works only with a local path.
Instead, check the domain name in the RewriteCond:
RewriteCond %{HTTP_HOST} ^(www\.)*exampledomain\.com$ [NC]
RewriteRule (.*) http://httpd.apache.org/$1 [P,L]
But using mod_alias or VirtualHost would be a more correct decision here.

500 Internal Server Error for sub domain using htaccess in SilverStripe 3.1

I am getting a 500 server error for a sub domain. It was working perfectly before installing SilverStripe 3. Is there any modification needed in the default .htaccess created by SilverStripe installation?
This answer makes a few assumptions from your question.
These assumptions are
Your SilverStripe website is the root website (e.g. http://www.example.com)
Your SilverStripe code is in the root web directory (e.g. /public_html)
You sub-domain code is in a sub-folder of the root web directory (e.g. /public_html/sub
The problem that can occur in the above situation is the sub-domain may use the /public_html/.htaccess file and use its mod_rewrite rules.
To solve this we can create a .htaccess file in the sub-domain (/public_html/sub/.htaccess) with the following code:
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase /
</IfModule>
This will tell the server to not use the mod_rewrite rules or base of the root .htaccess file.
An alternative solution could be to not place sub-domain code in a sub-folder of the root web directory. You can create a folder on the root level such as /sub and have your sub-domain point to there.
Thanks every one for their support, but I follow different method.
I have created sub domain from cpanel, but selected same root folder instead of creating new directory.
I got the help from here.
https://forums.cpanel.net/threads/domain-redirecting-to-cgi-sys-defaultwebpage-cgi.139597/page-3#post-656642

Setup website with / prefixed URLs to run in sub-directory

I am trying to host a website that is setup with links in the format /css/file.css and /js/file.js and I'd like to set it up in a sub-directory on an existing domain for demo purposes.
So
/demo/css/file.css is the true path
But the demo/index.php references
/css/file.css
I can have a custom .htaccess file within the sub-directory.
Is this possible without touching the main site on my domain?
If the request is for /css/file.css then rules have to be placed in root .htaccess not in /demo/ directory.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^((?:css|js)/.+)$ /demo/$1 [L,NC,R=302]

Resources