?
Solved

url rewrite help

Posted on 2014-08-15
9
Medium Priority
?
187 Views
Last Modified: 2014-08-28
Hi, i have one page like this:
http://localhost/app_g/Default.aspx?id=173&S=1&M=12

I want to be rewrite like this:
http://localhost/photos/173/1/12

how can i accomplish this changing my web.config file to do this. What should I change on the web.config file.
0
Comment
Question by:rafaelrgl
  • 5
  • 4
9 Comments
 
LVL 4

Expert Comment

by:Edward Cho
ID: 40263853
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 40263925
could you help me giving me one final solution to my problem, This link you show me is not working. can you provide me the syntax to add on web.config.
0
 
LVL 4

Expert Comment

by:Edward Cho
ID: 40264063
You should have a web.config like the one below:

<rewrite>
  <rules>
    <rule name="Rewrite to Default.aspx">
      <match url="^photos/([0-9]+)/([0-9]+)/([0-9]+)" />
      <action type="Rewrite" url="app_g/Default.aspx?id={R:1}&amp;S={R:2}&amp;M={R:3}" />
    </rule>
  </rules>
</rewrite>

Open in new window

0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
LVL 1

Author Comment

by:rafaelrgl
ID: 40264097
i got this error:
Server Error

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
0
 
LVL 4

Expert Comment

by:Edward Cho
ID: 40264107
What does the event log say?

I'm assuming you have IIS7 with ASP.NET role service enabled?  URL Rewrite Mod installed?
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 40264987
Hi Edward, The page is like that:
http://localhost/app_g/Default.aspx?id=173&S=1&M=12
I want to be like this.
http://localhost/photos/173/1/12

Question, is your code doing the opposite
0
 
LVL 4

Accepted Solution

by:
Edward Cho earned 2000 total points
ID: 40265000
Nope -- it is matching the second URL (via the "match") when the user types it in and the url rewrite mod translates it to the first for the server (basically so the server can understand the actual request).
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 40265096
Hi, i found this on the internet that say i need to change the global.asax file like this, but it does not give errrors and does not change the path.

<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">
    Sub RegisterRoutes(ByVal routes As RouteCollection)
        routes.MapPageRoute("test", "color/{id}/{*queryvalues}", "~/app_g/Details.aspx")
    End Sub
   
    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs on application startup
        RegisterRoutes(RouteTable.Routes)
    End Sub
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 40265226
ok, now i am starting to understand this. If i access the link:        
http://localhost:4565/app_g/Details.aspx?id=2 it will not change to the other page i route, but it will stay at this addres. But if I access this addres: http://localhost:4565/color/2/ it will work as the same. But what about if I access the first link with the ?id=2, is there anyway to change to the friendly path.

RouteTable.Routes.MapPageRoute("test", "color/{id}/{*queryvalues}", "~/app_g/Details.aspx")
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Screencast - Getting to Know the Pipeline
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question