How to let ".com" be part of the URL: Routing Error

Hi,

I am trying to list companies in a catalog. I have set following route
for that

map.connect 'company/:company'
            :controller => 'community',
      :action => 'search'

Now I have ".com" as a part of the company name(Amazon.com), then my app
flags out an error stating:
no route found to match "/company-profile/amazon.com" with
{:method=>:get})

How can i avoid this?

Regards,
SG

I'm guessing that having .com at the end of the URL is causing your
browser to attempt to process/download a file of type com. I would say
avoid storing the company name with the .com or replace the dot with
something more safe like Amazon-com or Amazon_com or something like
that within the URL. You want to make sure the web server and/or the
client browser does not interpret the .com as a file extension.

Or the simple solution is to just use the id of the row in the URL and
not worry about having the name there at all. Unless you expect the
end users to find your resources by typing in the full URL to them,
what difference does it make whether the URL is /company-profile/
Amazon.com or simply /companies/15? At least with the latter this
becomes a complete non-issue. There could be all sorts of "illegal"
characters that could appear in company names besides the dot. What
would happen with something like AT&T for example? Maybe it would
work, but who knows.

I personally prefer my URLs in the standard REST conventional way: /
users/5, /companies/35. This is of course unless I really want to
provide useful permalinks when it makes sense to do so. Something
like /2008/jan/reports/top-sales.

I'm guessing you're not expecting your end users to have to find
companies in your catalog by typing in: http://company.com/compan-profile/amazon.com.
I would guess the user would instead click on a "Company Catalog" link
and be presented with a page full of links to the various companies in
the catalog. Where in that process would the end user care anything
about what shows up in their address bar in the browser?

It seems sometimes that programmers put more work on themselves for
virtually no benefit when the end user could care less.

Hi Robert,

Thanks for the detailed analysis.
I agree with you almost 99%.
Only reason behind using company names in the permalink is to let
crawlers have more readable URLs than have ids.

I don't know if my assumption is true too, if it were true, we would
have to go extra mile than just REST conventional way.

Please comment.

Regards,
SG

Interesting... I'm certainly no experts on web crawlers/robots, but I
would think they would be more interested in the page's contents than
the URL's content.

I would assume that any link that ended in something like Amazon.com
would likely contain Amazon.com or at least Amazon in the page
contents. I wouldn't see any particular advantage of having that
string in the URL. That would just be redundant. Why would a robot
need a readable URL? They would be just as happy with
http://67.25.34.28/1234/4764/xxyz-5739384. They would still follow any
links on the page and index any string content and keywords that it
finds there.

Unless it's a really smart robot I wouldn't expect it to see
amazon.com in a URL and then start guessing that there might be links
on the site to other companies and start throwing it random URL
looking for other companies.

I'm trying to think of any benefit of having the string in the URL,
but I just can't think of any. Strings (permalinks) are designed for
humans not robots. In fact I don't believe the original designers of
the internet would ever have dreamed that end users would end up
typing things like http://www.somecompany.com/index.html in order to
find a page on the World Wide Web. The whole URL system we're so used
to today was designed for computers to talk to computers. The fact
that whole think is exposed to the end users was entirely
unintentional.

I'm going to respectfully disagree with Robert W...

I believe that bots will in fact look at the URL, and if a key word is
in the URL (and in the actual content of the file) then it is more
likely to rank higher on search engines (for that keyword). This is
just my understanding by reading very basic SEO articles...

The WWW has changed since the original designers sent their first TCP/
IP message. For instance, that's the whole point behind DNS - so that
a mere mortal doesn't have to remember an IP address in order to reach
a web host.

Using model IDs is the easiest solution without a doubt, and works
great for "private" webapps where SEO is not a concern. If you want
pretty perma-links, you'll have to craft your routes and probably use
gsub in the process to get rid of unsafe characters such as spaces,
dots, amps, etc. Also, take a look at permalink_fu plugin which is
supposed to help in exactly this (I have not used it).

-Harold

Understood. Which is why I was clear I am not an expert on the matter.
I just find it unfortunate that address bars became the way users
access resources on the web. That is evident by the fact that the
transport protocol "http://" is exposed to the user. I don't think
URLs were ever intended for direct use. It just tuned out to be that
way.

So, I guess the lesson to be learned here is that it doesn't matter if
your page contains interesting content. If you want a good ranking
just make sure your URL looks interesting. And we wonder why search
engines are cluttered with 3 pages of garbage before you find a link
that actually contains interesting content.

But, that being said what Harold suggests is probably exactly right.
It's just illogical enough to be correct.

I am by no means an SEO expert and don’t claim to be one. Just throwing out there my two cents…

There are too many factors that will influence your search engine rankings, from keywords in your URLs, to number of times keywords appear in the content, but more importantly, how many people link to your site, are you linking to high ranked sites, how much time do users stay on your site (not just breeze through it and go away in 5 seconds), etc, etc, etc. People really abuse the keyword on the content “trick” as well as the URL “trick”, so my guess is that ranking algorithms will adapt too, and avoid pointing people at useless 'link famrs".

Again, I am no expert.

Cheers!

Of course, I realize that. I hope it's clear that I'm just being a bit
sarcastically cynical about this. It just seems like there must be a
better way that would work for both developers and users. "The Web" is
what it is, and we have to do the best we can to accommodate an
imperfect system.

Sandeep Gudibanda wrote:

Hi,

I am trying to list companies in a catalog. I have set following route
for that

map.connect 'company/:company'
            :controller => 'community',
      :action => 'search'

Now I have ".com" as a part of the company name(Amazon.com), then my app
flags out an error stating:
no route found to match "/company-profile/amazon.com" with
{:method=>:get})

How can i avoid this?

map.connect 'company/:company',
            :controller => 'comunity',
            :action => 'search',
            :company => /.*/