what is the url rewriting?how to rewrite the url? give any
example



what is the url rewriting?how to rewrite the url? give any example..

Answer / chinnu

If you don't like having meaningless URL's for your
visitors (i.e index.aspx?id=3&pid=3932), consider URL Re-
writing. With URL rewriting, you can store all your content
in the database while having user-friendly URL's. Here's a
code snippet to do just this:

void Application_BeginRequest(Object sender, EventArgs e)
{
String strCurrentPath;
String strCustomPath;
strCurrentPath = Request.Path;
strCurrentPath = strCurrentPath.ToLower();
// the URL contains this folder name
if (strCurrentPath.IndexOf( "/SomeSubFolder/" ) > -1)
{
strCustomPath = "getContent.aspx?id=" +
Path.GetFileNameWithoutExtension( strCurrentPath );

// rewrite the URL
Context.RewritePath( strCustomPath );
}
}

The getContent.aspx will take the page name as a parameter
and do a lookup in the database and return the content for
the page. I have left the details out because the point of
the code snippet is to show how to rewrite the URL and get
the data from the database.

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More PHP Interview Questions

how can i upload only pdf files in my website? files has not a pdf extension mantioned

0 Answers  


What are the different ways we can retrive the mysql results using php ? Explain each

1 Answers  


How to find second highest salary

9 Answers  


Is age an interval or ratio?

0 Answers  


Will react hooks replace redux?

0 Answers  






Why super () is used in java?

0 Answers  


what is the maximum size of databasi in mysql?

4 Answers  


Is multilevel inheritance possible in php?

0 Answers  


i have saved the password in encrypted format in database. now i want how to retrive the password in decrypted format.

6 Answers  


If the variable $var1 is set to 10 and the $var2 is set to the character var1, what's the value of $$var2?

0 Answers  


How are variables declared in php?

0 Answers  


How we get ip address of client, previous reference page etc?

0 Answers  


Categories