rafaelrgl
asked on
url rewrite help
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.
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.
ASKER
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.
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}&S={R:2}&M={R:3}" />
</rule>
</rules>
</rewrite>
ASKER
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.
Server Error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
What does the event log say?
I'm assuming you have IIS7 with ASP.NET role service enabled? URL Rewrite Mod installed?
I'm assuming you have IIS7 with ASP.NET role service enabled? URL Rewrite Mod installed?
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.Rout ing" %>
<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
<%@ Import Namespace="System.Web.Rout
<script runat="server">
Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.MapPageRoute("test"
End Sub
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
RegisterRoutes(RouteTable.
End Sub
ASKER
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.MapPageR oute("test ", "color/{id}/{*queryvalues} ", "~/app_g/Details.aspx")
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.MapPageR
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module