I have my website running at:
www.example.com
I also have this other domain:
www.example.net
Is it possible to point "www.example.net" to a subdirectory of "www.example.com"? For example:
www.example.net-> www.example.com/other
?
It's not just a redirect, I need to serve the pages and see "www.example.net" in the user's browser.
What do you think?
We use IIS7 and everything is ASP.NET (aspx pages, ascx controls, etc).
Using ISAPI Rewrite
[ISAPI_Rewrite]
RewriteCond Host: (?:www\.)?other\.com
RewriteRule (.*) http://www.domain.com/other$1 [I,L]
You're looking at two methods for this:
URL rewriter
Server.Execute method
The first is a httpmodule that silently redirects the request without changing the url in the address bar, the second is a method you can call within aspx code. I think the latter is only good though if you're working in the same application, so I would go with the URL rewriter.
There is an official iis7 URL rewriter available on www.iis.net afaik.
-Oisin
Two questions for you:
Can you set them up as two different web sites in IIS?
If someone visited example.net/page.htm, would that be the same as example.com/other/page.htm?
If the answer is yes to both of those, why not just setup a new web site in IIS and point it to the "other" file path.
Related
Hello - I'm using IIS 7.5 to host a web site with several web apps. For the sake of discussion, let's say it is comprised of the following:
http://hostname/app1
http://hostname/app2
I have a bunch of users that use http://hostname/app1 as their bookmarked hyperlink but I want to delete that app and replace it with app2. In my case, app2 has a more appropriate name so I can't just overwrite app1's content.
Is there a way to redirect users to app2 when they browse to app1 within IIS? I tried the Http Redirect but it appears to work for the whole website and I just want to apply it to one application. I see the Url Rewrite tool but it seems like overkill and I'm just trying to replace a visit to the app's main page, not rewrite urls...
Thanks!
You could in theory, empty your site's pages and replace their content with:
<meta http-equiv="refresh" content="0; url=http://hostname/app2" />
If you are looking for a catch-all scenario, URL Rewrites would be ideal. For example http://hostname/app1/page1 http://hostname/app1/page2 may not get caught with below without replacement in both places.
ASP.NET 3.5, VB.NET
We have a website, e.g. hosted with an external web host.
We want to get a SSL certificate so that the site can be https. Our webhost said they will "install" the certificate on the server for us.
Once they have done that, how do we make it so when someone types www.oursite.com into their browser, it automatically goes to https://www.oursite.com and not http://www.oursite.com?
Also, we have many hardcoded links in the site that point to various other pages on the site but use the full URL, e.g. http://www.oursite.com/somefolder/somepage.aspx
How do we make it so those links end up going to the https version of the page?
Create a file and rename it ".htaccess" to ur public_html.
it will add auto redirect links to "https://" protocol.
write ur own website adress..
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourwebsite.com/$1 [R,L]
For automatically redirect http to https you can ask your webhost.Normaly they can do. Check this link for others methods
For hardcoded links: Replace 'http' or 'https' with '//', for example instead of http://yoursite.com/script.js use //yoursite.com/script.js .However I recommend to use relative path, if it's possible.
For Web control or server controls you can use Tilda "~" or Control.ResolveUrl. for example :
<asp:HyperLink NavigateUrl="~/views/view.aspx" runat="server" />
<a href="~/views/view.aspx" runat="server" >
ASP.net 4.0 / IIS7.
I want to "alias" a single web form to appear as various extensionless urls. Given a form in my web root called "mySite.com/ColorWebForm456.aspx":
I want it served as multiple names, e.g., mySite.com/Color, mySite.com/Colour, mySite.com/Colors, mySite.com/Coler, etc., without creating folders and duplicate forms with those names.
I never want mySite.com/ColorWebForm456.aspx displayed in the browser, it needs to display as mySite.com/Color, even if the user somehow acquires it and types in that exact ~.aspx address.
The variations will account for several alternate or mis-spellings users might attempt - I don't want them "corrected", however. So, if a user types in mySite.com/Colour, the url is NOT rewritten to mySite.com/Color, but the same page is served via ColorWebForm456.aspx as the requested "mySite.com/Colour".
I've seen so many articles on this that I'm not even sure where this would be best handled: in Global.asax, IIS7 URL Rewrite, web.config, etc., and I'm not even sure this is technically a case of url rewriting or routing... ?
You can achieve this with ASP.NET 4 routing for web forms, or if you are using MVC its available too: http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx
Except potentially for #3; it would work, but you would have to explicitly declare the variations you want. In that case, rewriting supports regular expression matching, so that might be better for what you are looking for.
I had issues setting up URL rewriting and various aspects of web forms, so be aware. There is some setup required for a rewrite module potentially (I could have done it wrong too), where URL routing is already built in and handled.
HTH.
If you have a rewrite engine available:
(using ISAPI Rewrite .htaccess syntax)
# redirect any requests for the filename back to the friendly URL
RewriteRule ^/colorWebForm4567.aspx(.*) /Color$1 [NC,R=302]
# rewrite /Color requests to the web form
RewriteRule ^/(Color|Colour)/(.*) /ColorWebForm4567.aspx$2
Following article expalins it all, but if you will be using a web host after you complete your application I would check with the hosting provider first to see if they are offering everything you need to have:
http://learn.iis.net/page.aspx/496/iis-url-rewriting-and-aspnet-routing/
Hope this helps!
As a side note: Search engines dislike it, if you publish content under different URLs ("duplicate content").
So my recommendation would be to stick with one (rewritten) URL, not multiple (rewritten) URLs for the same content.
My goal is to implement the following scheme using the subdomain and path as attributes:
Use a wildcard DNS entry that routes any subdomain to the root site:
Example:
*.example.com
ex: http://xyz.example.com
to
http://example.com
Next I want to rewrite the requests to point to a specific page, passing both the subdomain and the request path as attributes.
Example:
http://xyz123.example.com/images/header.jpg
to
http://example.com/get.aspx?id=xyz123&path=/images/header.jpg
I've seen several questions on here regarding similar goals, but not quite the same. I'm new to using rewrite rules, so any help is appreciated. I will update this as I make progress.
for IIS7, url rewrite functionality is built-in. Rules are set in web.config. For IIS6 you need an ISAPI dll that does the same for you. Use IIRF, it works just fine.
How do I rewrite a URL in ASP.NET?
I would like users to be able to go to
http://www.website.com/users/smith
instead of
http://www.website.com/?user=smith
Try the Managed Fusion Url Rewriter and Reverse Proxy:
http://urlrewriter.codeplex.com
The rule for rewriting this would be:
# clean up old rules and forward to new URL
RewriteRule ^/?user=(.*) /users/$1 [NC,R=301]
# rewrite the rule internally
RewriteRule ^/users/(.*) /?user=$1 [NC,L]
Microsoft now ships an official URL Rewriting Module for IIS: http://www.iis.net/download/urlrewrite
It supports most types of rewriting including setting server variables and wildcards.
It also will exist on all Azure web instances out of the box.
I have used an httpmodule for url rewriting from www.urlrewriting.net with great success (albeit I believe a much earlier, simpler version)
If you have very few actual rewriting rules then url mappings built in to .NET 2.0 are probably an easier option, there are a few write ups of these on the web, the 4guysfromrolla one seems fairly exhaustive but as you can see they don't support regular expression mappings are are as such rendered fairly useless in a dynamic environment (assuming "smith" in your example is not a special case then these would be of no use)