SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,878
    Mentioned
    46 Post(s)
    Tagged
    0 Thread(s)

    Getting Current Url with C#

    Hey guys

    I have a bit of a problem. We have an SEO guy here, that says I must put a 301 redirect on http://www.domain.com/videos/page.aspx to go to /videos/ and IIS has page.aspx as the default start document. Which works fine.

    The problem is, even if ur on page.aspx it must redirect to that url and remove the page.aspx part.

    So my question is, how do I check if the user is on:
    /videos/page.aspx
    or
    /vidoes/

    which is essentially the same page?

    Request.Url always gets page.aspx weather its in the url or not and the redirect puts the page into a continuous loop.

    Thanks for any help/feedback

  2. #2
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hello

    hello, i'm not sure , it this what u want?

    Request.ServerVariables.Get("PATH_INFO");

    http://www.aspcode.net/List-of-Reque...Variables.aspx

  3. #3
    SitePoint Addict
    Join Date
    Feb 2005
    Location
    Clogland
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you running IIS7? If so you can use the IIS7 rewrite module with something like this:

    Code XML:
    <rule name="Default Document" stopProcessing="true">
     <match url="(.*)page.aspx"/>
     <action type="Redirect" url="{R:1}" redirectType="Permanent"/>
    </rule>

  4. #4
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,878
    Mentioned
    46 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by newbieLeo
    hello

    hello, i'm not sure , it this what u want?

    Request.ServerVariables.Get("PATH_INFO");

    http://www.aspcode.net/List-of-Reque...Variables.aspx
    Gives the same result as Request.Url

    Quote Originally Posted by SlitheryImp
    Are you running IIS7? If so you can use the IIS7 rewrite module with something like this:
    Unfortunately not.

    Im beginning to think that this is a bit of an overkill, doubt its gona make such a difference to google rankings doing this...

  5. #5
    SitePoint Addict
    Join Date
    Feb 2005
    Location
    Clogland
    Posts
    322
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only other option I can think of is ISAPIRewrite
    Im beginning to think that this is a bit of an overkill, doubt its gona make such a difference to google rankings doing this...
    It depends on who you ask maybe it's worth asking in the Search Engine Optimisation Forum

  6. #6
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Really, not much makes a difference in google rankings save real, quality backlinks. You know, the kind of stuff you get by having quality content and a site people want to visit. SEO types don't believe that because they would then have to do real work. I think the SEO point he is hitting on is that you technically have duplicate content going on as /video/ and /video/page.aspx are going to the same place.

    Anyhow, shouldn't be too hard to make the 301 redirect work, what you want to look at is HttpRequest.Url.Segments -- it returns an exploded array of all the parts. Should be able to find the entry that ends with .aspx and trim back accordingly pretty easily.


Bookmarks

Posting Permissions

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