IIS setup with Vuejs and Laravel - laravel

In my Laravel + Vuejs project I have the following structure:
wwwroot/dist folder where the client application is located in /wwwroot/dist.
wwwroot/public folder, entry point of Laravel
The client application consumes a Laravel REST API. There are also other APIs for different utilities.
I have the following web.config file in /wwwroot. The idea is that all requests go to /dist to access the client app, except those coming from the api|src|flyer|admon|user subdomains. This is my web.config:
<configuration>
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="/public/index.php" />
<add value="/dist/index.html" />
</files>
</defaultDocument>
<handlers accessPolicy="Read, Execute, Script">
</handlers>
<rewrite>
<rules>
<rule name="specific routes" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern=".*(api|src|flyer|admon|user)\.mysite\.com.*" />
</conditions>
<action type="Rewrite" url="/public/index.php" appendQueryString="True" />
</rule>
<rule name="general routes" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="/dist/" appendQueryString="True"/>
</rule>
</rules>
</rewrite>
</system.webServer>
All requests that work with the first rule (api|src|flyer|admon|user subdomains) work correctly. The issue is that my client app doesn't work, it seems like it doesn't process Javascript files. Note that in the content of the JS files it shows that of index.html:
The problem is not in my Vuejs application, because I have it installed on another Apache/Linux machine and everything works correctly with the same deployment structure.
EDIT
This is my virtual path config in Azure, where my web.config is placed:

Related

Point subdomain to it folder IIS

There's a way to point all my subdomains to the same name folder, using Windows Server | IIS - Rewrite Rule or Proxy?
Example:
subdomain1.domain.com ----> C:\customers\development\subdomain1
subdomain2.domain.com ----> C:\customers\development\subdomain2
subdomain3.domain.com ----> C:\customers\development\subdomain3
Is it possible do automatically?
I've tryied these web.config rules
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rewrite" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www\.)(.*)\example\.com$" />
</conditions>
<action type="Rewrite" url="/{C:1}/" appendQueryString="true" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Thanks in advance!
URL rewrite is mainly used to rewrite URL not physical path. So you have to create a web app with root folder C:\customers\development and bind all subdomains to this IIS site. Then modify your rule to
<rule name="rewrite" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www\.)(.*)\.example\.com$" />
</conditions>
<action type="Rewrite" url="/{C:1}/{REQUEST_URI}" appendQueryString="true" logRewrittenUrl="true" />
</rule>
Please modify ^(?!www\.)(.*)\example\.com$ to ^(?!www\.)(.*)\.example\.com$.
Finally, you should be point subdomain to subfolder
Besides, if the application in folder domain1/domain2 and domain3 are three independent projects then you need to use sub-application instead of a folder.

Laravel 5 on IIS7 does not work with web.config

I have a simple Laravel 5 app. It was developed on Xampp, and worked perfectly. I copied it onto the production server, and it does not work. Something is wrong with the web.config file, because if I remove it, then the app works perfectly with index.php/path
My webconfig is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rule 1" stopProcessing="true">
<match url="^(.*)/$" ignoreCase="false" />
<action type="Redirect" redirectType="Permanent" url="/{R:1}" />
</rule>
<rule name="Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
The app is located at a subfolder of the website and I cannot create a new site, but I can restart IIS as needed. I really don't know IIS very well (in fact I hate it), so I don't know where to check, but since the app works without the web.config, I assume it must be the culprit.
IIS Needs to have the URL Rewrite Module for the Laravel web.config to work.
On XAMPP, it will work out of the box as the Apache mod_rewrite module is included and most of the configuration settings are already provided by XAMPP.
Microsoft URL Rewrite.
Download it from here

URL rewrite - odd url is produced

My first attempt at doing an URL rewrite.
Usual scenario. Domain name seperate from host.
So I've changed the name servers and domain points to holding page at host so that's ok.
And purchased a domain pointer from the host to allow for a domain to be pointed at a sub folder.
Added the following code to web config file in root folder:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="xyz.uk" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?xyz.uk" />
</conditions>
<action type="Redirect" url="\xyz\ {R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I get "The page isn't redirecting properly" and my url reads as "http://www.xyz.uk/%5Cxyz%5Cxyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/xyz/"
Googled this and all the examples I've seen are the same as the one I'm using.
Where am I going wrong?
Thanks in advance.
The actual code that works is below.
TIP.............I was helped on another forum and even though I made the changes, the page still wouldn't redirect.
PROBLEM WAS..........the browser cache was remembering the old redirect url!!
CLEAR DOWN your browser cache and any changes can then be seen immediately. Happened in Chrome and Firefox.
Correct code:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="xyz.uk" stopProcessing="true">
<match url=".*" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?xyz.uk" />
<add input="{PATH_INFO}" pattern="^/xyz/" negate="true" />
</conditions>
<action type="Redirect" url="xyz/{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Http Redirect within web.config using wildcards not working

My need is to tell IIS, within the web.config to ignore some URLs and to send a HttpRedirect to the client.
To do so, I added the following magic into web.config :
<system.webServer>
<httpRedirect enabled="true" httpResponseStatus="Temporary" exactDestination="true">
<add wildcard="*/iac*; " destination="http://someServer.smthg.be/iac$S$Q" />
</httpRedirect>
</system.webServer>
When I try to make a request, to eg ´myserver/iac/john?doe=hello´ I only receive a 404 not found instead of the 302 I expected.
<rewrite>
<rules>
<clear />
<rule name="test" stopProcessing="true">
<match url="^iac/(.*)" />
<action type="Redirect" url="http://someServer.test.be/iac/{R:1}" appendQueryString="true" redirectType="Temporary" />
</rule>
</rules>
</rewrite>

How do you use [RequireHttps] in a Rackspace Cloud Site

I am trying to use [RequireHttps] in Rackspace Cloud Site, but I am just getting a redirect loop message when I hit any actions that use the attribute. I have talk to support, but they are not much help. Has anyone got [RequireHttps] working in a MVC 3 site on rackspace cloud sites?
I was having this same problem. I finally found a knowledge base article on Rackspace's site.
http://www.rackspace.com/knowledge_center/article/how-do-i-force-ssl-on-my-aspnet-site-on-cloud-sites
The web.config option worked just fine, just be sure to remove the [RequireHttps] attribute from your code (it isn't needed).
I have copied it below for simplicity.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_CLUSTER_HTTPS}" pattern="^on$" negate="true" />
<add input="{HTTP_CLUSTER_HTTPS}" pattern=".+" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{SCRIPT_NAME}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Resources