How can I forward a url to the appropriate page?

2019-05-15 04:13发布

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

6条回答
唯我独甜
2楼-- · 2019-05-15 04:29

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]
查看更多
何必那么认真
3楼-- · 2019-05-15 04:30

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.

查看更多
We Are One
4楼-- · 2019-05-15 04:35

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

查看更多
5楼-- · 2019-05-15 04:35

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

查看更多
聊天终结者
6楼-- · 2019-05-15 04:51

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.

查看更多
ゆ 、 Hurt°
7楼-- · 2019-05-15 04:51

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

    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

查看更多
登录 后发表回答