• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL Rewriting

 
Parth Bhagat
Greenhorn
Posts: 7
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one explain the concept of URL Rewriting? I am having confusion with that.

Confusion is:
1.) URL Rewriting is used for Session tracking, by sending parameters/values to the URL as with get request.
2.) URL Rewriting is used for SEO, to make URL readable & easy to remember.

Can any one brief about the concept itself?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That Wikipedia article covers only half of it, namely the #2 of Parth's question. That's the part where the external URL that the user (or a search engine) sees is different from the internal URL that the web app actually handles.

The first part is about changing a URL that is generated in the web app *before* it is sent out. Thus the altered URL is the same externally and internally. The only difference is the addition of the session cookie, though, which the servlet container handles, and not the web app code.
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch Parth

URL rewriting is basically changing/ modifying the URL from what it should have been to something that either helps to maintain session (like when cookies are disabled) and other things like adding security, SEO, etc.
So lets say my original URL for a successful admin login page was http://foo.bar/admin I would rewrite it to http://foo.bar/admin?authkey=blahblahblah&session_token=blahblahblah.
Now both the above URLs server the same page and purpose. The latter one adds up two query string params to avoid cookies but still have some sort of authentication data in the request.
You can try disabling cookies in your browser to check out the difference in the URLs for most sites that use this approach, you will likely notice the jsessionid being appended at the end of the URL when you disable cookies. Although not all sites work can work that way.

Hope this helps.
 
Parth Bhagat
Greenhorn
Posts: 7
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for your valuable reply.

Here is what I understood from these replies.
1.) For SEO purpose: It is done with the help of Rewrite Engine running on Web server.
2.) Session Tracking: In case when Browser Cookie is disable, using encodeURL method of HttpServletResponse instance session can be tracked for current transaction to the application.

Session tracking with URL Rewriting.


Please correct me if I am wrong at any point.

Thanks again for your responses.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic