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>
Related
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:
so I uploaded my website in GoDaddy and I used a Windows Hosting (Plesk). My only problem is that since it isn't running Apache as far as I know, it won't read my .htaccess file, which has all of my mod_rewrite code to remove the index.php in the URL. So my question is how do I implement a mod_rewrite in Plesk?
You can rewrite .htaccess file to IIS's web.config and place it inside /httpdocs folder.
You can do it by guides like this or this online converter or if you have Windows Server you can convert .htaccess by this guide (or you can share your .htaccess and i'll try to convert it for you)
I've found this snippet maybe it can help you:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Index">
<match url="^(.*)$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
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
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>
I have a solution with multiple projects, the transforms work in other projects but not this one. What could be the reason?
The project is an MVC 4 application
The configuration manager for the solution shows that when the solution configuration is LIVE then it should use the LIVE configuration for the project.
There is a Web.config, Web.Live.config, Web.Stage.config
In the Web.Live.config I have this code:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.web>
<compilation debug="false" xdt:Transform="SetAttributes"></compilation>
</system.web>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I publish it to my web server, ensuring the configuration is set to Live.
The web config on the server does not contain the transformations.
Any ideas?
I've solved this, it seems in this situation I had to add xdt:Transform="Insert" to the <rewrite> tag.
I don't know why I need that considering the default template for a transformed config file contains markup that inserts code without such an attribute that works ok...