views:

269

answers:

6

How can I forward a url such as:

http://www.mysite.com/Join

to the appropriate page:

http://www.mysite.com/JoinOptions/MemberRegistration.aspx

Is there some way to do this?

I'm using a DNN CMS but if you're unfamiliar with DNN and still have a solution for redirecting that would be helpful.

Thanks,
Matt

A: 

If you are using Apache you can create or edit an existing .htaccess file containing:

RewriteEngine on
redirect 301 /Join http://www.mysite.com/JoinOptions/MemberRegistration.aspx

And place it in your root directory (the directory that http://www.mysite.com/ points to) It may be useful to read up on Apache .htaccess files and mod_rewrite in addition to this.

Edit: Oops. Didn't check the tags.

Andrew
Considering the `dotnetnuke` and `asp.net` tags, chances are slim that OP is hosting on Apache ;)
Jørn Schou-Rode
that's right, we're not on Apache. thanks though
Matt
You can use Managed Fusion URL Rewriter which supports Apache syntax under .NET. http://urlrewriter.codeplex.com
Nick Berardi
+1  A: 

We once used a DNN module from SnowCovered, you can get it here: http://www.snowcovered.com/Snowcovered2/Default.aspx?tabid=242&PackageID=7262

It's $15 but it will do what you need to without any coding.

You will create a page that is /Join and redirect it to /JoinOptions/MemberRegistration.aspx

Russ Bradberry
Note: If you want to have http://yoursite.com/Join (as opposed to Join.aspx) handled by asp.net you'll need to have wildcard mapping set up in IIS for the web site. DNN will handle the extensionless request, but it won't be forwarded to DNN without making the change in IIS first.
Ian Robinson
A: 

Actually without touching IIS and without spending any money you can do this with a little trickery.

  1. Create a folder called JOIN at the root
  2. Add a page called default.aspx in that folder
  3. add the code below

    <%@ Page language="VB" %> <%@ Import Namespace="DotNetNuke" %>

    Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
    
    
    Dim DomainName As String = Null.NullString
        Dim ServerPath As String
        Dim URL() As String
        Dim intURL As Integer
    
    
        ' parse the Request URL into a Domain Name token 
        URL = Split(Request.Url.ToString(), "/")
        For intURL = 2 To URL.GetUpperBound(0)
            Select Case URL(intURL).ToLower
                Case "admin", "desktopmodules", "mobilemodules", "premiummodules"
                    Exit For
                Case Else
                    ' check if filename
                    If InStr(1, URL(intURL), ".aspx") = 0 Then
                        DomainName = DomainName &amp; IIf(DomainName &lt;&gt; "", "/", "") &amp; URL(intURL)
                    Else
                        Exit For
                    End If
            End Select
        Next intURL
    
    
        ' format the Request.ApplicationPath
        ServerPath = Request.ApplicationPath
        If Mid(ServerPath, Len(ServerPath), 1) &lt;&gt; "/" Then
            ServerPath = ServerPath &amp; "/"
        End If
    
    
        DomainName = ServerPath &amp; "JoinOptions/MemberRegistration.aspx"
    
    
        Response.Redirect(DomainName,True)
    
    End Sub

If you change the Page name you would have to re-edit the file but it works

note:might have to replace the amersan amp with an actual ampersand

codemypantsoff
didn't work...I tried replacing all the with ampersands
Matt
A: 

If you are on IIS, you can use ISAPI_Rewrite3 tool. The .htaccess for the site will be:

RewriteBase /
RewriteRule ^Join/?$ JoinOptions/MemberRegistration.aspx [NC,R=301,L]
TonyCool
+3  A: 

You can create a "friendly URL rule" within DNN. In the Host Settings page, open the Friendly URL section within the Advanced Settings section. From there you can add a new rule, that matches .*/Join/Default.aspx and replaces it with ~/JoinOptions/MemberRegistration.aspx (I'm fairly sure that using that style of URL will work, but I know that you can replace with a URL like ~/Default.aspx?tabid=423).

Using this scheme, you need to make sure that IIS lets ASP.NET process the request. The easiest way to do that is to add a "Join" folder in your file system with a file called Default.aspx.

bdukes
Worked perfectly, thanks!
Matt
Wow - I never thought of doing that
codemypantsoff
This only works if that is the first portal on the dnn instance
codemypantsoff
A: 

Yet another option. Probably a little bit more of a hack than the accepted answer.

Enable wildcard mapping in IIS

This allows extensionless URLs to work (e.g. http://yoursite.com/Join)

  1. Web site -> right click -> properties
  2. Home directory tab -> configuration
  3. Mapping tab -> wildcard section -> "insert"
  4. Browse to aspnet_isapi.dll (see example path below) -> select file
  5. un-check "verify file exists" check box
  6. ok ok ok ok until done -> close IIS window

Create a page in DNN called "Join" and redirect it to the desired page

Add a page with the name/title Join, set it to not show up in the menu, and set it to 301 redirect to your desired URL (these are all options in the page's settings)

* typically something like C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll

Ian Robinson