Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hello. Absolutely New here. Dumb noob needs 301 redirect help.

    Hello everyone. I found these forums looking when the other forums where just not paying attention to me. What I found is that you guys actually communicate, if at least to say, "I don't no, but you can try this"

    In any case, here's my problem.

    I have a website running an asp.net 1.1 e-commerce solution in the root. This application has no room for content management, so a created a sub-folder called more/, and installed a CMS called DotNetNuke.

    I've decided to move to a different application, for performance purposes, and for web search purposes as well. I know how to do a redirect in asp.net, so I figured that I'd do it hardball style and actually create folders and pages that corresponded to the originals, and just pop in a 301 redirect to the new application pages, as they corresponded.

    In other words, those DNN pages that had a url of more/HelpFAQ/tabid/56/Default.aspx, as was going to create a folder called 56, inside of a folder called tabid, inside of a folder called HelpFAQ, and stick a default.aspx page in there with a 301 redirect to the new url and corresponding page.

    I know, this method might seem very dumb, but easy to understand and easy to implement.

    However, my dnn application has some other, WEIRD urls. For instance

    more//OutdoorFabrics/SuggestedFabricCombinations/tabid/54/AlbumID/417-22/Default.aspx

    In bold, you can see that heres a url that looks like there is a folder with no name. You can't do that.

    I was hoping to find an asp.net script, preferably VB 1.1, that will do the following.

    just one default.aspx page in the more/ folder, with an argument that says

    If uri = more/HelpFAQ/tabid/56/Default.aspx
    Then 301 redirect to (new page)

    If uri - more//OutdoorFabrics/whatever/default.aspx
    Then 301 redirect to (new page)

    I found this code:

    If InStr(Request.Url.AbsoluteUri, "www") = 0 Then
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("http://www.yoursite.com" & Request.RawUrl)
    End If

    So I'm wondering if I could use it like this

    If InStr(Request.Url.AbsoluteUri, "www") = http://www.cushionsandumbrellas.com/...5/Default.aspx

    Then
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("http://articles.cushionsandumbrellas.com/outdoor-fabric-417.aspx" & Request.RawUrl)
    End If

    Any help would be appreciated.

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    No; InStr() returns an index, not a string.
    So this won't work.

    If InStr(Request.Url.AbsoluteUri, "www") = http://www.cushionsandumbrellas.com/...5/Default.aspx

    Actually, I can't tell what you even wanted that to be.

    Were you trying to compare the URL to a specific string, or ?

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Were you trying to compare the URL to a specific string, or ?
    No, not a string, but the url of an incoming request.

    I guess I gummed up the explanation. I'm sorry.

    I'm trying not to spam these forums, but I need to post some url's for example.

    cushionsandumbrellas.com/more/OutdoorFabrics/tabid/53/Default.aspx
    cushionsandumbrellas.com/more/OutdoorFurnitureCushionGuide/tabid/36/Default.aspx
    cushionsandumbrellas.com/more/OutdoorFurnitureCushionGuide/ReplacementCushions/tabid/69/Default.aspx
    cushionsandumbrellas.com/more/TrustedPartnersandResources/HomeImprovementResources/tabid/75/Default.aspx

    These are some examples of the urls that I'm talking about. They are the product of a url rewrite from within DotNetNuke. However, they are not too "friendly" really, and I'm going to use a new web app that does create SE and People friendly urls.

    Like I said, what I was going to do was create an actual folder structure within the more/ folder that would mimic what these "friendly" urls look like. Inside of each, I would place an empty default.aspx file, with a 301 redirect code to the new page.

    I now, hardball, but quick and dirty.

    However, because of certain urls, like
    cushionsandumbrellas.com/more//OutdoorFabrics/SuggestedFabricCombinations/tabid/54/AlbumID/417-5/Default.aspx

    I've got a problem. That double slash behind the more folder, I can't create an no name folder.

    So, I was hoping that I can create just one default.aspx file in the more/ directory, and use an argument for each possible url, only about 30, to 301 redirect those urls to the new page. The urls would be treated like static urls.

    As you noted, the code I found would not do this. I was hoping that someone would know of a way or describe how I could create this argument. I am not a coder by nature, I just string together pieces of code that will have the desired affect.

    Thank you very much.
    Last edited by rumblepup; 01-09-2007 at 08:05 AM.

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Correct me if I'm wrong, but it seems you want to redirect every one of the URLs that have those double slashes to one specific page, right?

    If so I think this might work.

    If InStr(Request.Url.AbsoluteUri, "//") > 0 Then
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("http://www.yourNewUrl.com")
    End If

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #5
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sounds right.

    So, if I create one default.aspx file in the /more directory, and insert in the code behind
    If InStr(Request.Url.AbsoluteUri, "//") > 0 Then
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("http://www.yourNewUrl.com")
    End If
    all of the pages with the double slash should 301 redirect to the specified url?

  • #6
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Honestly, I have no clue.

    Assuming the request uri did in fact have double slashes, works in theory.
    How the request uri ends up with double slashes by the time default is hit, I have no idea. I've never done redirects like this.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •