I'm using Umbraco 4.7 and I am trying to use the UrlRewriting.config file to set up a domain level URL redirect.
So for example, if a user hits the website at the following URL
www.OLD-Domain.com/join.aspx
I want rewrite the URL permanently to:
www.NEW-Domain.com/join.aspx
I'm hoping that the search engines will be able to see this too when they next visit the site to re-index it.
Examples/Ideas please?
If you don't want to use IIS redirects or sites to do this, then you can use an Umbraco config file to do the job for you:
Go to your "Config" directory in your main Umbraco website directory.
Edit the "URLRewriting.config" file in your favorite text editor.
Add the following code between the (paste here) tags:
<add name="SEOfix" virtualUrl="^http://domain.com/(.*)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="http://newdomain.com/$1" redirect="Domain" redirectMode="Permanent" ignoreCase="true" />
<add name="SEOfixSSL" virtualUrl="^https://domain.com/(.*)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="https://newdomain.com/$1" redirect="Domain" redirectMode="Permanent" ignoreCase="true" />
Save the file and test.
See more at: http://www.proworks.com/blog/2011/03/31/permanent-301-redirect-domaincom-to-wwwdomaincom-in-umbraco/
Related
TL/DR: Can multiple rewrites (and a final redirect) for the same URI resource be chained over multiple web.config files living in subfolders along the URI's path during the same request?
I'm trying to migrate my classic ASP website from one shared virtual host to another; the new one using IIS7.5. My website has lots of subdomains, and the new hoster defaults to use one true website instance per subdomain, but my plan then only allows for a few of these subdomains, and since they're extremely low-traffic, one webserver instance should do perfectly fine. I therefore want the one main website instance just serving up all subdomains.
My path on their server is something like D:\websites\myaccount\mysite\wwwroot. For cleanliness sake (to separate all files for the subdomains in their own folders) I've set up a single folder for each subdomain in my hosting root folder (so at e.g. D:\websites\myaccount\subdomain1), and added virtual folders mapping names under the wwwroot to these subdomain folders (e.g. the virtual folder subdomain1 maps to D:\websites\myaccount\subdomain1).
I then added rewrite rules to the main wwwroot folder's web.config to intercept requests for the subdomains and rewrite them to map to the virtual folders;
<rule name="Subdomain support" stopProcessing="false">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(subdomain1|subdomain2|subdomain3)\.mysite\.com$" />
</conditions>
<action type="Rewrite" url="{C:1}/{REQUEST_URI}" />
</rule>
Using this, requests to http://subdomain1.mysite.com/dir1/file.asp indeed do get served nicely via the subdomain1 virtual folder from D:\websites\myaccount\subdomain1\dir1\file.asp.
I now want each subdomain to be able to add it's own rewrite rules to the mix. The most important one is that requests for the root of the subdomain should get mapped to a default file in the most appropriate language subfolder. Directly inside the subdomain1 folder I thus have another web.config file, holding:
<clear />
<rule name="subdomain root redirect to proper language subpath" stopProcessing="true">
<match url="^$" />
<conditions>
<add input="{HTTP_ACCEPT_LANGUAGE}" pattern="^(en|nl|de|es)" ignoreCase="true" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{C:1}/index.asp" redirectType="Found" />
</rule>
<rule name="subdomain root redirect to default language subpath" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="http://{HTTP_HOST}/en/index.asp" redirectType="Found" />
</rule>
This should redirect the browser from subdomain1.mysite.com to subdomain1.mysite.com/en/index.asp (if your preferred browser language is set to "en.*").
However, I'm unable to get these rules to be picked up at all, no matter what I do. I've tested this by even matching .* and changing the redirects to point to e.g. google.com, but the server just serves me a 403 forbidden, and when I add:
<directoryBrowse enabled="true" />
I'm getting served the folder listing of the subdomain's folder itself. My redirects are starting to scream "Do I mean nothing to you?!", and I want to stop the screaming.
However, when I type in subdomain1.mysite.com/subdomain1/, the redirects do get picked up... I've also tried rewriting into regular (non-virtual) folders under the wwwroot and that exhibits the exact same symptoms.
Am I misguided in thinking this is possible? Could it be that since the original URI doesn't contain the (written-in) intermittant ...\subdomain1\... part in the folder path that IIS doesn't take that folder's web.config into account?
My first attempt was to use .htaccess (.irwaccess) files, but I soon found out they do not inherit (right?), so that was my reason to look into web.config files.
Your requirement is redirect subdomain1.mysite.com to subdomain1.mysite.com/en/index.asp.
Then rewrite to subdomain1.mysite.com/subdomain1/en/index.asp right?
If you enable FRT, you will see that redirect rule under subdomain1 will never been executed. This isby design.
In this case, you should just move all these rules to the root folder's web.config and modify the order like this:
Mix rule in root level and application level is supported by IIS but I think your rules can't be separated in this case.
I'm experiencing a strange issue with the umbraco back-office. The umbraco version is 7.5.3. Inside umbraco back-office when i try to open a node of Settings or Users tab , either templates, partialviews, stylesheets, etc, automatically a .aspx file is generated and downloaded and the node gets loading infinitely. For example clicking Create in templates a file create.aspx is generated and downloaded. Clicking in any of the templates a file EditView.aspx is generated and downloaded.
In chrome console appear the following:
jquery.min.js?cdv=865237568:3 Resource interpreted as Document but transferred with MIME type application/octet-stream: "http://localhost:54531/umbraco/settings/Views/EditView.aspx?treeType=templates&templateID=3289".
The same problem happen both in back-office local environment and back-office production environment. Fortunately the page in production has not problem but I can't access into the nodes into the back-office. Please, any help would be very appreciated. At the end, an image of the logs. Any other information required about the issue please let me know.
Tracking in version control I realized that I had deactivated the ImageProcessor module by commenting the following line in web.config:
<!--<add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web" />-->
but this line:
<add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />
which was added previously when I installed ImageProcessor.Web.Config also was necessary to comment it. so I commented too and the problem dissapeared.
net site on a shared hosted server with plesk as admin panel. And I want my 404 redirected to default page to handle extentionless urls
I have in the plesk panel pointed with url the following.
Error description type location
404 Not found Url http://iservice.iwebdesigner.org
however when I use the url like this http://iservice.iwebdesigner.org/user
it redirects to the default page but looses the /user. I believe the type which is not available on plesk needs to be set to execute url for iis. Is there a way of changing that in plesk? or what else can I do. I am not sure is web config settings can help as iis will have already redirected the page and the extension gone before web config settings can run.
The hosting people say the cant make any changes what so ever to iis.
Thanks
Ok I have figured it out. For those of you trying to use the urlrewriter module
in your shared hosted server. This rule below handles non existent extentionless
url and redirects to default.aspx for processing. e.g www.mysite/user. Once you
have set the 404 error page to point to the default.aspx as above in plesk(Type
must be url and the path set to default.aspx), upload the UrlRewritingNet.UrlRewriter.dll
to your bin folder. in web config
<configsections>
<section name="urlrewritingnet"`enter code here`
requirePermission ="false"
type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" />
</configsections>
<urlrewritingnet rewriteonlyvirtualurls="true" contextitemsprefix="QueryString" defaultpage="default.aspx"
defaultprovider="RegEx" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
<rewrites>
<add name="ExtensionlessRewrite" virtualUrl="^~/(.*)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="/default.aspx" ignoreCase="true" />
</rewrites>
</urlrewritingnet>
<system.webserver>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
</modules>
</system.webserver>
That worked for me echo
I'm looking to use the URLRewriting.config within Umbraco to set up some redirects. The majority of them are working fine, but a few are causing headaches.
I have a page: /testpage.aspx which on the new site is now under /directory/testpage.aspx. I've tried a couple of rules, but they either fall into a loop, or just send me to the first page - which obviously gives a 404 error.
As far as I can tell, the rule below should satisfy this rewrite and work, but instead I'm just getting the original page - which is a 404 on this site.
<add name="Redirect400" rewriteUrlParameter="ExcludeFromClientQueryString" redirect="Domain" ignoreCase="true"
virtualUrl="^~/testpage.aspx$"
destinationUrl="/directory/testpage.aspx"
redirectMode="Permanent" />
Those regular expressions (please correct me if I'm wrong), should be saying that any page that starts and ends with /testpage.aspx is redirected to the new URL? Can anyone offer any assistance on this?
there is bit change in your virtual URL because that only gets which has www.domain.com/testpage.aspx
It will not get following results:
www.domain.com/abc/testpage.aspx
www.domain.com/abc/main/testpage.aspx
www.domain.com/abc/main/test/testpage.aspx
Please try following, I haven't tested it but I am guessing it is that.
<add name="Redirect400" rewriteUrlParameter="ExcludeFromClientQueryString" redirect="Domain" ignoreCase="true"
virtualUrl="^~(.*)/testpage.aspx$"
destinationUrl="/directory/testpage.aspx"
redirectMode="Permanent" />
let me know if you need more help
thanks
I have a php Facebook application which I have uploaded in a Microsoft server. When I run the application i get this error. Does anybody know the cause of this ?
405 - HTTP verb used to access this page is not allowed. The page you
are looking for cannot be displayed because an invalid method (HTTP
verb) was used to attempt access.
Even if you are using IIS or apache, in my guess you are using static html page as a landing page, and by default the web server doesn't allow POST or GET verb on .html page, facebook calls your page via POST/GET verb
the solution would be to rename the page into .php or .aspx
and you should be good to go :)
In the Facebook app control panel make sure you have a forward slash on the end of any specified URL if you are only specifying a folder name
i.e.
Page Tab URL: http://mypagetabserver.com/custom_tab/
you can add these lines to the web.config:
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
It means litraly that, your trying to use the wrong http verb when accessing some http content. A lot of content on webservices you need to use a POST to consume. I suspect your trying to access the facebook API using the wrong http verb.
I fixed mine by adding these lines on my IIS webconfig.
<httpErrors>
<remove statusCode="405" subStatusCode="-1" />
<error statusCode="405" prefixLanguageFilePath="" path="/my-page.htm" responseMode="ExecuteURL" />
</httpErrors>
I've been pulling my hair out over this one for a couple of hours also. fakeartist appears correct though - I changed the file extension from .htm to .php and I can now see my page in Facebook! It also works if you change the extension to .aspx - perhaps it just needs to be a server side extension (I've not tried with .jsp).
Try renaming the default file. In my case, a recent move to IIS7.5 gave the 405 error. I changed index.aspx to default.aspx and it worked immediately for me.
In my case, IIS was fine but.. uh.. all the files in the folder except web.config had been deleted (a manual deployment half-done on a test site).
I got this error when I was using jquery and lib was not present in the given path, once jquery lib is added back error was gone.
[File name - calculate.html]
I had this err on the host too (my project was .net core2.1 webapi )
please add this code in web config in host :
<modules>
<remove name="WebDAVModule" />
</modules>