Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

URL rewriting has become quite popular, but I think it only adds more complexity to the Web. Old fashioned URL's are often called "dirty URLs", so I'll use that term.

It is argued that with rewriting it makes the URL more "discoverable" but how is it more discoverable with this URL

www.magic.com/date/2010/02/02 

than this URL?

www.magic.com/date=2010-02-02

I believe people would discover more with the old fashioned URL than the rewrite URL.

With the good old fashioned URL, using ampersands and equal signs, you are actually telling the search engines how they relate to each other. With slashes you can't. They don't know that /2010/02/02 is actually a date or how the numbers relate to the /date/. It merely assumes that it's a different directory with different data. With date=2010-02-02 I believe it'll allow search engines to figure out how they relate to each other.

Dirty URLs can easily be shortened with URL shortener services, but everyone copies a URL and pastes it; they don't write it. It's much simpler if they write down a dirty URL that's well laid out. A URL like goo.gl/8aPtuI seems more cognitively difficult than generic.com/awesome.

I read an argument that search engines stop at URLs that look dynamically generated, but I am skeptical. Virtually all websites are dynamically created, so why would they stop there?

I'd also think that dirty URL's can be meta-rich if you do it right.

www.generic.com/rate=5&name=Allen&sex=m 

and it's much easier for engines to see how they are related than doing this,

www.generic/com/rate/5/name/Allen/sex/m. 

What are the real advantages?

share|improve this question

migrated from stackoverflow.com Apr 19 '11 at 4:56

This question came from our site for professional and enthusiast programmers.

    
This is arguable: and it's much easier for engines to see how they are related than doing this. The "engine" receives the same input, as the webserver (usually) handles the rewriting. –  Blender Apr 18 '11 at 22:16
    
And I doubt Google "reads" the parameters and processes them in some way, so I don't think Google cares. –  Blender Apr 18 '11 at 22:18
    
+1 good question –  Johan Apr 18 '11 at 22:19
    
Take this example: www.buy.com/product.aspx?id=321654 compared to www.buy.com/books/computer-science/what-are-the-benefits-of-url-rewriting –  MikeEast Apr 18 '11 at 22:22
    
@Mike of course, that would be bad URL but you can make it clear like www.buy.com/book?title=what-are-the-benefits and people can easily add category/author/price pairs to the URL to narrow down. –  netrox Apr 18 '11 at 22:54
add comment

3 Answers 3

I wouldn't so much call it "URL rewriting" so much as "having a sane URL schema". There is a good and bad place for everything.

In the example you give, you are absolutely correct; you have an unordered set of 'parameters' as it were, and the key=value&key2=value2&... syntax is excellent for that.

However with the date example you give, there is a nice hierarchical structure. So for example if your site had a monthly listing, you could do www.magic.com/date/2010/02 for an index page with choice of days, or a yearly listing you could do www.magic.com/date/2010 for an index of months (and maybe a sidebar with days), and www.magic.com/date for an index of years and/or something similar.

It all comes down to what is elegant. Unnecessary URL rewriting (you gave a perfect example) can be as inelegant as a path shoved into key=value query. And only savvy users will bother manually rewriting the URL.

As some other answers point out though, one should take care not to leak internals. For example it is very bad practice to do /mypage.ext?internalThing=blah&... because then everyone knows you're using ext. You should not show the extension of your script. Let's say you want to change mypage.php to mypage.py or something; then (as other answers suggest) this will confuse search engines. This is a separate concern than URL rewriting though; for example it would be just as bad to do /mypage.ext/category. It is probably just a correlation that the people who aren't aware of URL rewriting also aren't aware that /mypage.ext?... links are bad practice.

On the other hand, URL rewriting can require integration with the web server, which may be time better spent on other things.

share|improve this answer
    
Thanks for excellent explanation. I thought the extension doesn't matter - you can make any webpage work with Apache module extensions - you can change a php file to be executed with your preference of extension? –  netrox Apr 18 '11 at 23:01
add comment

When I was learning about URL rewriting, I found some good articles

An Overview of URL Rewriting and Its Benefits

URL rewriting - benefits and implications

Also:

  1. SEO friendly. If re re engineer the site lets say from asp to aspx then we can keep the same extension but use different technology, so old site rating and ranking remains the same

  2. Powers the developers for rapid development of web applications or websites. Lets say we have content pages that we manage from CMS and based on them we show in front end, in earlier days we have to create pages at front end but using the URL rewriting we create single page at front end and use URL re writing to inter prate as n different pages

  3. Security: It will make site more secure as malicious user will not be able to get to know the structure of the application

  4. We avoid the query-string and use URL rewriting to pass on data among various page calls

share|improve this answer
    
thanks, didn't realize URL rewriting can discourage hotlinking. –  netrox Apr 18 '11 at 23:10
    
netrox: I don't think highly of the first article at all, and it is slightly misleading. URL-rewriting has no effect whatsoever on hotlinking, unless you are periodically changing your URL, in which case you're also periodically destroying your search engine rankings. To deal with hotlinking, you detect the HTTP referrer from the user-agent and block the site. –  ninjagecko Apr 19 '11 at 0:58
add comment

One good opinion I like:

"I think the prime reasons are usability and search engine optimization. From the SEO perspective, I think you can get keywords into the URL rather than ID#'s. For your users, it is easier to navigat a site with:

mysite.com/products/tools/hammers/stanley

than:

mysite.com/products.aspx?id=43245&cat=33&subcat=867&manfuacturer=854

The user can just take off sections of the URL to navigate up a level. I am sure there are a lot of other goof reasons, but those are some main ones."

And from security point of view:

It will make site more secure as malicious user will not be able to get to know the structure of the application

And a quote from Google Blog:

Keep in mind, however, that dynamic URLs with a large number of parameters may be problematic for search engine crawlers in general, so rewriting dynamic URLs into user-friendly versions is always a good practice when that option is available to you. If you can, keeping the number of URL parameters to one or two may make it more likely that search engines will crawl your dynamic urls.

share|improve this answer
    
The claim "I think you can get keywords into the URL rather than ID#s" seems rather unfounded, as you could just have /products?id=43245, or /products?cat=tools&subcat=hammers&manufacturer=stanley –  ninjagecko Apr 18 '11 at 22:26
    
"mysite.com/products.aspx?id=43245&cat=33&subcat=867&manfuacturer=854" is just as bad as url rewriting IMO. If I were the make it, I'd do like this: mysite.com/products?product=Ruffles&manufacturer=Lays –  netrox Apr 18 '11 at 23:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.