views:

61

answers:

1

My freelance web developer is developing a site on Ruby on Rails. Currently the URL structure is

http://abc.com/all?ID=category

Example:

http://abc.com/all?3=CatA

I requested him to structure the URL according to categories, such as

http://abc.com/CatA/3-page-title

but he refused cos it was too much work and cost involved as he is using the same model for Category A, Category B... I thought the URL structure that he is using is messy and not search engine friendly.

My question is, should I add cost to let him do a better structured URL I requested, or should I let the project finish, then do it in the next iteration?

I'm worried that if I do it in the next iteration, all the previous URLs structured in the old way will be purged and when sites that refer to it will show a 404 error. It's like I have to rebuild the site ranking all over again.

Any other solutions for me? Is that any way to redirect old URLs to new URLs automatically in Rails?

+4  A: 

The way your developer is proposing to compose the URLs would be considered something of an anti-pattern is Rails. What you are looking for is close to what Rails does out-of-the-box when using RESTful resource routing, admittedly, I'm guessing as to how CatA and page-title are related to each other. A RESTful Rails route might look like this (using your example):

http://abc.com/categories/3-CatA/pages/10-page-tite

If he really is using Rails, and he knows what he's doing, then there should be no cost at all to converting to what you want. It just needs the correct routes defined and then a to_param override in your models to get the nice SEO friendly identifiers.

bjg
He says that all categories are using the same object model. I'm expecting the route to be:http://abc.com/CatA/3-page-titleinstead of the one you show.Mind to refer me some articles how to achieve that?
Victor
@bjg did an excellent answer, to make a route it's a matter of 1 or 2 lines code, so it's not a big work ;)to get a route like you asked in comment, it may depend by the models' relationships which hopefully are *correct*.by the way it's possible :)
apeacox
@Victor The problem with a route such as the one your are proposing is that it difficult to extend the scheme if you need to add more models because it's not obvious that the first part of the path is a category id. But if you want to do this you can add a rule to `routes.rb` such as `map.connect '/:category_id/:id' :controller => "pages", :action => "show"`. More here: http://guides.rubyonrails.org/routing.html
bjg
Thanks @bjg. I will look into it. I am still learning RoR. Hopefully I could do something for my web startup.
Victor
I just got back from meeting with my developer, and had a look at the database table. The current database is like this: name of database table is ALL. All data is in it. There is one column called CATEGORIES. So as entries go per row, the value for column CATEGORIES in each row is either A, B, C. That is why it formed the URL that I didn't want. Any comments?
Victor