Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4831

Accommodating mod_rewrite urls

$
0
0

@midget2000x wrote:

I have a client running a traditional server-side application who is OBSESSED with their SEO-friendly urls. They look like this:

http://www.site.com/shirts/t-shirts/childrens // category url (i.e. nothing in the url indicates it's a category)

http://www.site.com/shirts/t-shirts/childrens/pink-shirt.html // product url (only indication it's a product is that the path matches a category and the url ends in .html)

I'd like to eventually convert them to Ember but I know URLs are going to be an issue with them. Even though rewrites and redirects could still be handled by the server, they are not gonna like seeing this:

/category/233

in the location bar. I'm wondering if I could set up the ember routing to mimic their current url structure, and if so, if that's a reasonable approach.

If it is reasonable, probably the easiest thing would be to use the path elements (like 't-shirts') as the id for the model (rather than a number). Then, (and I don't know if this is possible) but I'm thinking in the router.js file I could load a JSON object like:

{
	"categories": {
		"shirts": {
			"t-shirts": {
				"childrens": "",
				"adults": ""
			},
			"sweatshirts": {
				"childrens": "",
				"adults": ""
			}
		},
		"hats": {
			"baseball": "",
			"cowboy": ""
		}
	}
}

Then maybe split the incoming route by '/' and loop through the elements and then progressively test each iteration against that object.

If the loop completes and there's a match, then it's a valid category - use the last element as the ID.

If the loop completes and everything matches except the last one, and the last one has .html at the end, it's a product, use last element as the product ID (sans .html) and use the matched path to generate the breadcrumb trail.

That's shooting from the hip. I just wanted to explore the issue here and see if this would be a reasonable approach and if so, if anyone has done something like this. Thanks!

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4831

Trending Articles