English 中文(简体)
How can I forward a url to the appropriate page?
原标题:

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.

  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

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)

  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:WINDOWSMicrosoft.NETFrameworkv2.0.50727aspnet_isapi.dll





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签