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
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.
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
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.
Actually without touching IIS and without spending any money you can do this with a little trickery.
- Create a folder called JOIN at the root
- Add a page called default.aspx in that folder
add the code below
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 & IIf(DomainName <> "", "/", "") & URL(intURL)
Else
Exit For
End If
End Select
Next intURL
' format the Request.ApplicationPath
ServerPath = Request.ApplicationPath
If Mid(ServerPath, Len(ServerPath), 1) <> "/" Then
ServerPath = ServerPath & "/"
End If
DomainName = ServerPath & "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
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]
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)
- Web site -> right click -> properties
- Home directory tab -> configuration
- Mapping tab -> wildcard section -> "insert"
- Browse to aspnet_isapi.dll (see example path below) -> select file
- un-check "verify file exists" check box
- 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