Hi
We have a CMS application that lets people create websites under our domain.
The system was built a few years ago and it used a method that transfers parameters such as website id, folder code and more using the url. this method created a giant url for every item in the website
For example:
My domain is www.domain.com
A users website on my domain is www.domain.com/user
and every time that a user enters his website he gets a link like this
www.domain.com/page.aspx?code=blablasdsdsdsdsds&folder=blablablablablabla and more.
We are trying to reduce the string size in the url.
What are our options? can we show the user one url like a virtual one and still work the same with the old url?
We are trying to locate a solution that wont make us rewrite our entire application.
the application is built in c# and the web server is iis 6.
Thanks
You are searching for URL rewriting.
For IIS7 this functionality is build-in via the URL Rewrite Module.
For IIS6 you should read this MSDN article to follow the details on how to do it:
URL Rewriting in ASP.NET
Or you could go with one of the numerous third-party tools to do it:
UrlRewritingNet.UrlRewrite
UrlRewriter.NET
Ionics Isapi Rewrite Filter
ISAPI_Rewrite
Related
I have an ASP.NET MVC web app running on Azure as generic-site.co. It's a white-label site that supports a number of subdomains: acme.generic-site.co, globex.generic-site.co, initech.generic-site.co, etc. Browsing to each of them changes branding on the pages, but the underlying functionality is exactly the same.
Meanwhile I have an external domain name acme-site.com hosted by GoDaddy. I want to redirect this specifically to the acme.generic-site.co subdomain, but I also want to maintain acme-site.com as the root URL for any further browsing on that site, allowing users to have a pure acme experience without any indication of the underlying generic-site-ness.
I've tried to do this using GoDaddy's Domain Forwarding with masking, but I ran into CSRF issues almost immediately.
Is there any way I can achieve this? I suspect IIS URL rewriting might be helpful, but I'm at a loss as to how to proceed.
Don't use Domain Forwarding with masking.
Just add custom domain acme-site.com to Azure Web App.
And you may need to do one of the following:
Add a middleware or something that change Host in HTTP request header from
acme.generic-site.co to acme-site.com.
Adjust the application to
load correct branding when using domain acme-site.com.
It is probably easier to use IIS Url Rewrite module as you mentioned in your question. There are several examples on how to do this. Please start with this post by Scott Forsyth: https://weblogs.asp.net/owscott/iis-url-rewrite-redirect-multiple-domain-names-to-one
Is there any way in ASP Classic to catch HTTP request before it comes to that page? Like in ASP.Net we can catch request at Application_BeginRequest.
Actually what I'm trying to do is to redirect requests to some other pages if asking files from a certain directory. My application is hosted on IIS6. And I suppose IIS6 by default doesn't support for url rewrite. Directory browsing is already disabled.
It would be nice if it could be done just putting a web.config in that certain directory to redirect to other pages.
e.g.
Original Requests:
Https://stackoverflow.com/NoReadWriteFolder/file1.asp
Https://stackoverflow.com/NoReadWriteFolder/file2.html etc
and I'd like to redirect to
Https://stackoverflow.com/ReadOnlyFolder/someOtherFile1.asp
Https://stackoverflow.com/ReadOnlyFolder/someOtherFile2.html
I googled but so far no luck, any clue would highly be appreciated.
background:
My application runs for different companies (countries in actual fact) that use the same application.
I use include file called default.asp that runs as standard include for all the scripts I serve. I catch domain requests in URL, detect which company this and then redirect to a URL that I build that includes company code and a "URL prefix" which is added to the URL throughout the session.
To do this, I read URL using request.servervariables, set Session variables, work out my URL prefix and based on this, create revised URL which I then response.redirect.
I hope this may give you an idea for your situation.
For IIS6 I have used Ionic's Isapi Rewrite Filter
https://iirf.codeplex.com/
It supports URL re-writes and re-direction and should do exactly what you need.
On the examples and help pages there are examples for you to re-direct.
i have setup a website and using IIS7, now what i want to do is when user hits the domain, it should take the user to another page, for example say user hits m.abc.com, url should be rewrited to m.abc.com/section/news, however /section/news should not be displayed in the addressbar, but the page should be news, in short i want url rewrite directly on root
There are basically two ways for doing url rewriting:
Using IIS add-in: http://www.iis.net/download/urlrewrite
Using asp.net url wriritng with http handlers: http://msdn.microsoft.com/en-us/library/ms972974.aspx
IIS has an add-in that you can install just for this purpose
http://www.iis.net/download/urlrewrite
I have an existing site in php running on Apache using the mod_rewrite plug-in. In other words, I currently have urls like www.example.com/section/subsection/ which Google and others have indexed.
However, the site needs a major upgrade, and I would like to move it to asp.net. I only have the option of using a shared hosting solution (iis 6, aps.net 3.5, full trust). So my question: How do I make asp.net do a 301 redirect from my old urls like www.example.com/section/subsection/ to their equivalent ones on the new asp.net site?
I obviously needs this to not loose the current rankings in the search engines.
Thanks, Egil.
If you use the ASP.NET MVC framework it has a URL rewriting system built into it.
You can manually add 301 redirects into IIS using IIS Manager if you want to set up "moved" locations.
If you want to do URL re-writing then you will need to implement IHttpModule, hook up the BeginRequest event, and add that new class to the httpModules section in Web.config.
Okay...so this may be overkill and could possibly be done another way in two lines..BUT...
If you are keeping the same domain name then what I've done in the past is keep a table of old urls and how they map to new urls. On the application's request, I'll scan the table, if an old url is found then I'll add a header that does a 301 redirect to the new URL.
According to Steve Sanderson’s blog post Deploying ASP.NET MVC to IIS 6 it do not look like there is an option to do url rewriting/redirection with IIS6 in a shared hosting set up, where you cant manually configure IIS. Gah...
I am trying to create a very simple ASP.NET application that presents information retrieved from a database based on the URL, in a similar way to a wiki, but in this case the site is read-only. An example of a URL I'd like would be:
http://www.foo.com/bar
The application would then use "bar" as a SQL query parameter to show information from the database that matches "bar".
I've looked into many URL re-writer options for IIS6 (and this would be on a dedicated server), but I'm still not sure which one to use for this application.
To perhaps clarify, I only need to run the site from a single default.aspx file, but I want it to work as described above. The overall site logic will be very simple.
I am hoping that someone with more experience in this area can help me out -- I am looking for the simplest solution that will address this one scenario.
IIS6 only directs requests to the asp.net engine if that extension has been registered. By default the registered extensions are aspx ascx asmx etc...
If you cannot base you database query on a query string parameter (e.g. foo.com/default.aspx?query=bar) then the best you can do on IIS6 is a wildcard mapping. Basically this means that every request will be directed over to asp.net (including images scripts and styles.) obviously this will degrade performance.
To enable wildcard mapping right click on your site in IIS manager and go to Properties -> Home Directory -> Configuration -> Mappings at the bottom click insert and type in the path to the asp.net isapi dll (you can copy it from the aspx extension above) and uncheck 'Verify that file exists'.
After making the changes you'll be able to request foo.com/bar
(another method might be to make a request to foo.com/default.aspx/bar)
Just for the record, IIS URL Rewrite 2 supports this, you can install the extensibility samples that include a DB provider. Works on IIS 7+ only.
http://www.iis.net/download/urlrewrite
http://code.msdn.microsoft.com/rewriteextensibility