Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is overriding runtime?

941


What is scope of variable in php?

998


What is a helper function?

907


What is difference between static and constant?

969


Tell me how the result set of mysql be handled in php?

929


Explain the advantages of using PHP?

958


what is session_set_save_handler in PHP?

957


What is warning – “cannot modify header information – headers already sent”?

1016


How can I embed a java program in php file and what changes have to be done in php.ini file?

908


Is php 5.6 secure?

920


Is null empty php?

962


What is the difference between mysql_fetch_array() and mysql_fetch_assoc()?

994


How can we extract string "pcds.co.in" from a string "https://info@pcds.co.in" using regular expression of php? More on reg can you explain

934


Describe PHP error and logging information?

1014


Write the statements that are used to connect php with mysql

920