We have an azure hosted site at www.roburir.com (built in asp)
I am wanting to add a wordpress site at the url www.roburir.com/articles.
Have created and successfully deployed a wordpress site at:
http://robur-articles.azurewebsites.net
Have then written a rewrite code in the web.config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="SEOAzureRewrite" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^robur-articles.azurewebsites.net$" />
</conditions>
<action type="Redirect" url="http://www.roburir.com/articles{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
This redirect works, however I am getting a 404 error and the message:
You do not have permission to view this directory or page.
Have tried moving the webconfig to different folders but still no joy.
Any help would be much appreciated cheers!
You will need to create a virtual directory "articles" on your www.roburir.com site then deploy your WordPress site to it.
You can follow this article for a full description of the method:
https://blogs.msdn.microsoft.com/kaushal/2014/04/19/microsoft-azure-web-sites-deploying-wordpress-to-a-virtual-directory-within-the-azure-web-site/
Related
I'm working on a client application where they have a nested HTML-only app in a rooted subfolder of an otherwise ASP.NET application.
The domain name is changing for the HTML app only, and I need to be sure that the requests are routed to the new domain name. So, using the rewriteRules sounds like a perfect tool for this, but I'm doing something wrong and need another set of eyes.
The original URL is something like this:
https://example.com/folder1/folder2/app/index.html
The new domain is on an entirely different server and I want all requests from the app folder to go to the new domain name. Here is an example:
https://newdomain.com/folder1/folder2/app/index.html
Unfortunately, I'm doing something wrong that's probably obvious... I keep getting this URL in the redirect.
https://newdomain.com/index.html
Here is the web.config showing what I tried. It's in the app folder.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="RedirectHtmlApp" stopProcessing="true">
<match url="^(.*)$" ignoreCase="true" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www\.)?example\.com$" />
</conditions>
<action type="Redirect" url="https://newdomain.com/{R:0}" redirectType="Permanent" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
{R:0} and {R:1} both return index.html.
What is passed to {R:0} is relative. So if your web.config is in /folder1/folder2/app/{here} then "folder1/folder2/app/" are not passed along. If your web.config rule is in the root of the site-app above /folder1, then I am wrong, but if I am right, then you just need to include the path to the root of the app at the destination also. Given what you have above,
<action type="Redirect"
url="https://newdomain.com/folder1/folder2/app/{R:0}"
redirectType="Permanent" appendQueryString="true" />
I have a really harsh time trying to get Symfony 3 app work on IIS as website subdirectory.
Structure on IIS :
Application is called pfc and its poiting to directory pfc/web, (IIS is hiding root, because folder name is same as app)
This is web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="app_dev.php" />
</files>
</defaultDocument>
<rewrite>
<rules>
<clear />
<rule name="StaticFiles" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile"/>
</conditions>
<action type="Rewrite" url="{R:0}" logRewrittenUrl="true" />
</rule>
<rule name="Symfony 3" enabled="true" stopProcessing="true">
<match url=".?" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="./app_dev.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Entering dev.erp.loc/Test2/pfc ends up with:
like Symfony thinks of itself as a root application, which is not.
My best shoot was to use router.request_context.base_url, but it looks like it worked only in S2.
Now im stuck on something i can call half-way solution
By comment rewrite section in web.config i was correctly redirected to Identity Server, but after log in i get :
In order to fix it, i needed to uncomment rewrite section, to make routing work again, but it works only for browser, leaving it in this state will cause "no route found" in anther browser.
It would be nice to fix subdirectory routing in parameters.yml, which I fill anyway in deploy script, but if there is no other way I can edit web.config too.
Recently I needed to take care of similar issue and as side effect I solved this "problem". My URL without trailing slash is correct. The issue was that Chrome couldn't create canonical url form and made request to endpoint that Symfony don't need to interpret
can anybody help me with this please. I have IIS7 and the hosting says that the URL Rewrite module has been installed already. I even put into the bin directory the Microsoft.Web.Iis.Rewrite.dll
i can only use the web.config for the url rewrite configuration since I dont have access to the IIS manager (hosting restriction).
here is my code on the web.config:
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to list_cities.aspx">
<match url="^/state/([a-zA-Z]+)" />
<action type="Rewrite" url="~/list_cities.aspx?state={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
I still get the error, HTTP Error 404.0 - Not Found, when i go to
http://xxxxxxxx.com/state/CA/ . I have already searched the issue but I cant seem to find any solutions.
Can anybody please check my code. Thanks a lot.
I found the solution just now (not being an IIS expert...)
Change {R:1} for {R:0}
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite to list_cities.aspx">
<match url="^/state/([a-zA-Z]+)" />
<action type="Rewrite" url="~/list_cities.aspx?state={R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
Im trying to figure out how to setup a 301 permanent redirect for a website that is placed on a Microsoft-IIS/7.0 type server.
So let's say I have domain www.A.com and I want to redirect this to www.B.com I could use something like the following in my web.config file:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to WWW" stopProcessing="true">
<match url="A.com" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.B.com$" />
</conditions>
<action type="Redirect" url="http://www.B.com/{R:0}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
When placing the web.config in the root directory, the server responds:
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
Any suggestion why this 403 error is given?
Thanks in advance.
If you are getting a 403 error with a plain (default) web.config and totally vanilla Default.aspx, then there is a configuration problem with IIS. Most likely the app pool does not have rights to the base folder for the website. Sounds like you're in a hosted situation so contact the system administrator.
This should work and also be much simpler. You don't need URL rewriting, just HTTP redirect.
As for the 403, does the IIS application pool have read access to the folder at the root of your site?
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="www.B.com" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>
at first. I have searched and read here a lot and googling with bing but didnt find
the solution. In my local enviroment it just works. Iam no IIS Admin so ....
i try the following
My domain "http://mysite.com/" goes to my url provided by my hosting service
(discountasp.net)
I want that this url goes to the root/mysite/ virtual directory but i want that the
url stays on "http://mysite.com/". So i defined the following rule, but it doesnt
work for me.
here is my web.config that is placed in the root directory (generated by the IIS7
Remote Administration UI)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="mysite">
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="mysite.com" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?mysite.com" />
</conditions>
<action type="Rewrite" url="\mysite\{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
The "#Html.ActionLink" creates a link with the virtual directory
"http://mysite.com/mysite/"
I got it. Pointing my Domain directly on the subfolder and defining a Outbound rewrite rule on iis solves my problem.