Tricky set of redirections needed for URL Rewrite - url-rewriting

If I have a website, say my http://www.website.com, what is the best way to redirect traffic to a default.aspx page but not have that shown in the url?
So if the user goes to http://mywebsite.com they get redirected to http://mywebsite.com/default.aspx?lid=1234 but that is displayed as:
http://mywebsite.com?lid=1234
When my site goes live (obviously the site is not http://mywebsite.com, but the main url is not relevant) I want to be able to give them the url above.
At the moment its a bit tricky, when we gave them the URL, it didnt have a parameter lid, but now the system requires it.
I changed http://mywebsite.com to http://mywebsite.com/default.aspx?lid1234 by setting index.html as a higher default page and having the code http-equiv="refresh" content="0;URL=default.aspx?lid=1234"
That worked.
If I then apply the standard rewrite rule for removing default.aspx as shown here: http://kitsula.com/Article/URL-Rewriter-Remove-default.aspx-from-the-URL
It almost works. The redirect goes to http://mywebsite.com/?lid=1234
How can I get rid of the / after .com?

It seems like you are doing 2 redirects when a single rewrite should do the trick.
<rule name="test" stopProcessing="true">
<match url="^/?$" />
<action type="Rewrite" url="default.aspx?lid=1234" />
</rule>
If a user comes to http://www.website.com or http://www.website.com/ the url will be rewritten to http://mywebsite.com/default.aspx?lid=1234. (but in the user's browser, the displayed url will stay the same)

Related

Redirect Rule For IIS Sharepoint Site

We have our Sharepoint 2019 site set up, and everything is running fine. However, when a user clicks the Brand Bar "Sharepoint" in the top left header, it brings them to a broken page. Researched this, and it seems like this link cannot be changed in 2019, as others are having this issue.
https://social.technet.microsoft.com/Forums/en-US/1ef910ec-fb70-443e-bcf4-2d277dc11d2a/sharepoint-2019-on-premise-management-shell-not-working-as-expected?forum=SP2019
What we wanted to do is a redirect, so whenever they went to the broken link, it would just direct them to the real homepage for our sharepoint.
Example -
Broken link is http://servername/my/_layouts/15/sharepoint.aspx
Correct link is https://sharepoint.companyname.com/SitePages/Home.aspx
Here is what I came up with to add to the web.config file, but doesnt seem to be working.
<configuration>
<system.webServer>
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
<add wildcard="*_layouts/15/sharepoint.aspx" destination="https://sharepoint.companyname.com/SitePages/Home.aspx" />
</httpRedirect>
</system.webServer>
</configuration>
Any idea on what needs to be done here? Is this even possible? I didn't set up the sharepoint site here so I'm not sure how http://servername/my/_layouts/15/sharepoint.aspx even became the brand bar link.
Thank you!
If you want to redirect from servername/my/_layouts/15/sharepoint.aspx to sharepoint.companyname.com/SitePages/Home.aspx by iis url rewrite, you can try this rule.
<rule name="test6" stopProcessing="true">
<match url="^my/_layouts/15/sharepoint$" />
<action type="Redirect" url="http://sharepoint.companyname.com/SitePages/Home.aspx" />
</rule>
This has been resolved.
Not sure what happened, only thing I did was place the rule on the top most part of the tree in IIS where the server name is. Before I was putting the rule on the actual site in the drop down. I guess this makes sense since the URL I wanted to redirect had the server name in it.

Is there an error in my IIS7 Rewrite, causing it to add an HTTPS suffice to the url?

I set up up a redirect to redirect xyzUX.com > myServer/Subfolder
I thought there might be an error in my IIS7.5 Rewrite Rules. So I removed that part. But I left in an http>https Rewrite.
But I can't see anything in it that would cause the problem.
Problem browsing to > http://claynicholsUX.com gets rewritten to: https://claynicholsux.comhttps/
Result : that https suffix causes the page to not be valid (site not found)
Desired result: the suffix is not added
If I start with https://claynicholsux.com then no rewrite happens.
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{PATH_INFO}" />
</rule>
</rules>

Odd 404 during URL rewrite

Background: I'm forwarding incoming 80/443 traffic to \\SERVER2; TFS is running on \\SERVER3. I wish to route all TFS-related requests to \\SERVER3. I have to do it this way as I'm running Server Essentials on \\SERVER2, which is finicky enough to not work well under URL rewriting (almost as bad as SharePoint, but not quite).
Here's the only rule on the default website:
<rule name="TFS Rewrite" stopProcessing="true">
<match url="^tfs(.*)" />
<action type="Rewrite" url="http://server3:8080/{R:0}" />
</rule>
...and here's the Failed Request Log: https://1drv.ms/f/s!AodXF_j3BiWkhPAZwjnwC-rAecVgtw
Note the requested URL on line #87 of the PDF: http://server3:8080/tfs. I can browse to that internally just fine. The external URL is https://tfs.domain.com/tfs.
The next entry that's at all file-specific is the 404 itself, on line #165.
I just don't get this. It's a simple rule. Why would IIS turn up a 404 for a clearly valid and working URL?
EDIT
As a test, I added this condition:
<conditions>
<add input="{HTTP_HOST}" pattern="tfs.domain.com" />
</conditions>
Now if I browse to https://tfs.domain.com/, the default website loads.
This—together with the logs—would seem to indicate that while IIS is rewriting the URL, traffic isn't actually being routed to \\SERVER3.
What's going on here? This is a mystery.
OK, I got it working.
I'd installed both the URL Rewrite and ARR Modules, but I hadn't yet enabled proxy processing.
I created a dummy Reverse Proxy rule and was prompted to turn it on in IIS. I did so, deleted the dummy rule and now all is working as expected.

301 Redirect plugin for wordpress on windows server

I has a wordpress site on azure website, traditionally I has used Quick Redirect Plugin to redirect some pages to new pages, but this plugin not work on windows cuz is using web.config file instead .htaccess
There are any way to generate 301 redirects for certain page from wordpress when is hosted in windows server, I has searched some plugin to do this but not finded any.
MORE DETAILS:
Azure websites use subdomain for azurewebsites.net like myblog.azurewebsites.net, I am configure website url with other masking domain name and work well, but, I want to that when user browse myblog.azurewebsites.net/category/link redirect to www.mydomain.com/blog/category/link but with 301 redirect in web.config. I am traying several ways, with location and url rewrite but nothing work.
Example of rules used:
<rule name="CanonicalHostNameRule1" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="subdomain\.azurewebsites\.net/([_0-9a-z-/]+)" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>
Are you hosting your website with Project Nami?
Your wordpress site should still be using .htaccess, although I may be mistaken.
For redirection, I use Page Links To.

URL Re-Writing in Umbraco - Page Moved Under New Directory

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

Resources