Redirect 301 on Windows Server and ASPX - asp.net

how can I redirect the URL of my old site from:
http://www.example.com/subdirectory/page.asp?variable=value
to
http://www.example.com/page.aspx?variable=value
Server Windows with

As i read :
"Url rewrite is one of the best and quickest ways to improve the usability and search friendliness of your site. It can also be the source of near-unending misery and suffering."
So be aware that if you do too much redirection... you'll mess everything up, make it simple.
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
Try to use regular expressions, and make the least number of redirection you can. The more you can do with a single redirection, the best it is.

Related

Creating SEO friendly urls in Classic ASP

I have to make all links SEO friendly on our website.
I have the following url: http://newark.storeboard.com/board.asp?RegionID=353&ClassAdCatID=740&IsEvent=1&IsCoupon=0&IsBlog=0
I need it be: http://neward.storeboard.com/classifieds/events/ConcertsLiveMusic
I have no way of accessing the IIS so this has to be done thru code. Any ideas about how to achieve this would be greatly appreciated.
Many Thanks,
Paul
The standard way of solving this as far as I know is to use a rewrite engine in IIS (such as ISAPI_rewite or IIS7 url rewrite module)
However, you don't have access to IIS you say... That makes it tricky. Two thoughts come to mind:
1) Could you create a dynamic (asp) 404 page that then looks at the request header and does a transfer according to the page requested?
2) Or, and this is rather lame, could you create a static folder structure that goes some way to looking like that url structure?
If you upgrade to IIS7 and use ASP.Net then you can control the URL rewrite module from your code.
I've done something similar to Matts suggestion 1 in the past and it can work. The important thing is you make the 404 page directly feed the true page content and not do a redirect. Otherwise your defeating the point of SEF URLs for SEO gain.
From the few references I still have to the code. asp has a Server.Transfer() function but you may have issues that you can't pass query string parameters. I think I ended up streaming the real page through the 404 page using the MSXMLServerXMLHTTP object and Response.BinaryWrite().

Extensionless url rewriting / filtering url rewrites

I've done some url rewriting, always using the Intelligencia.UrlRewriter and it always worked fine. But now i want to achieve the following and somehow i can't get it right.
i want:
www.mydomain.com/products/books > rewrite to www.mydomain.com/products.aspx?id=books
this works fine, because i can set my criteria to /products/..
www.mydomain.com/mybook > rewrite to www.mydomain.com/productdetails.aspx?id=mybook
and of course i want www.mydomain.com/newbooks.aspx to function normally
and these last 2 don't work together.
is there a way i can tell my rewrite rule to only rewrite when there is no extension in my url? or is there an other trick?
Thanks in advance!
Well, a bit off the road, but try using ASP.NET Routing instead of URL Rewriter.
I was playing (and messing up) with the rewriter, and here on Stackoverflow I was advised to use Routing, and it is MUCH better (and easier when you get it).
You'll need some little changes to your ASPX files though, but very small.
I thought i'd solve this old, unanswered question. The problem with the extensionless urls turned out to be some configuration problem in IIS. Our system admin fixed this by allowing these urls and after that the rewriter had no problems picking up and translating the URLS.

is it possible to do URL re-write in asp.net?

I have developers working on a site for me, they have told me there is no possible way to re-write the URL so there is no second level category e.g.
Remove "/category" from this URL http://www.somesite.com/category/page.aspx
I understand that page.aspx can simply go in the root folder on the server however I don't want to do this as adding heaps of pages will slow down server load time
Do not believe them... It's easy and can be done for example by UrlRewriter.net library which is easy to use and open source. Also they can write own rewriter which is also not more then an hour of work, for example like here.
check whether it will helpful for your requirement: URL Rewriting in ASP.NET

Best practices for converting an existing website into a website with SEF URL

I've got a website that was created about an year ago and its been constantly revised since then. The website is coded in classic ASP, contains about ~50 pages -- some are multi-purpose, and contains old-school style links such as:
/news.asp?PageIndex=4
/news.asp?SearchString=Obama
/news.asp?SearchString=Obama&PageIndex=4
/news.asp?NewsID=1
I have IIRF v2 installed which allows access to URL rewriting functionality so this I do not have to worry about. What I am worried about is how to replace about 300 links to .ASP pages with SEF urls. As far as my understanding is concerned, I have to add a database query (to extract title of the record being linked) for each link.
I need advice on how to begin converting the website into a SEF URL powered website with as little code change as possible. Wrapper classes and tried-and-tested techniques and pointers to best practices will be appreciated.
If you want to do URL Rewriting without changing frameworks or anything, may I suggest that you take a look at IIS7 Url Rewriting Module?
However, if you are rewriting part of your application in .NET ... you might want to consider ASP.NET MVC. It already build simple built-in URL Rewriting module and definitely allows you to keep on using your old "WebForms" (if ASP.NET) or your classic ASP pages.
Don't forget to permanently redirect each and every old link to a new one (use 301 HTTP code).
At news.asp (and whatever other old pages you have) put something (a class? I don't know, I have never used ASP) that parses the old-style URL and redirects (with a HTTP redirect code) to the new URL.
I'm not trying to be funny here but seriously how long would it really take to convert 300 links manually? I really suspect that it would take less time than trying to find some automated approach.

ASP.NET Web Dev: Map one directory to another?

We are thinking of renaming our web directory schema to be more user friendly. However, we need any URL requests for the old directory structure to forward to the new one. so....
How do I forward requests for all of these:
http://mydomain.com/OLDdirname/
http://mydomain.com/OLDdirname/samesubdir/
http://mydomain.com/OLDdirname/samesubdir/samescript.aspx
to each of these respectively:
http://mydomain.com/NEWdirname/
http://mydomain.com/NEWdirname/samesubdir/
http://mydomain.com/NEWdirname/samesubdir/samescript.aspx
Any suggestions and perhaps some general guidance as far as gotchas?
You can use a number of things to do something like this. Basically, you're doing URL Rewriting. One of these products should help you get the job done:
ISAPI Rewrite
IIS Rewrite
opURL
IIRF
I use IIRF on many of my websites, and it has always worked without failing. You use regular expressions to define the rules, and it takes care of the rest. It would be extremely easy to setup a few redirects using IIRF.
http://cheeso.members.winisp.net/IIRF.aspx

Resources