Welcome Guest, Not a member yet? Register   Sign In
Re-rewrite URL - Best Way
#1

[eluser]daweb[/eluser]
Hi there,

actually I have a site with this URI structure:

www.mydomain.com/my-category/my-id-category

and

www.mydomain.com/my-category/my-product/my-id-product

What about the best way to transform that in:

A) www.mydomain.com/mycategory-3.html

and

B) www.mydomain.com/myproduct-128.html ? or www.mydomain.com/myproduct-3-128.html ?

Please, tell me the best way to do that, and if is better the first or second B) soluzion
#2

[eluser]Sbioko[/eluser]
Read about .htaccess.
#3

[eluser]OliverHR[/eluser]
To use html extension set URL suffix on config.php, and for URI's I use URI Routing.
#4

[eluser]daweb[/eluser]
Thank you about yours reply, but I think I need an extra help, if it's possible.

That's ok about url_suffix setting... clear, sure.

Actually, in my route.php I have:

$route['([a-z_-]+)/([0-9]+)$'] = 'schedule/category_list/$1/$2';
$route['([a-z_-]+)/([a-z_-]+)/([0-9]+)$'] = 'schedule/product_list/$1/$2/$3';

And my URL for category:
http://www.mydomain.com/red-cars/4
http://www.mydomain.com/blue-cars/5

I would want to obtain:
http://www.mydomain.com/red-cars-4.html
http://www.mydomain.com/blue-cars-5.html

And my URL for single product:
http://www.mydomain.com/red-cars/ferrari/403
http://www.mydomain.com/blue-cars/porche/405

That will be:
http://www.mydomain.com/ferrari-403.html (How to disting category and single product?)
http://www.mydomain.com/porche-405.html

Hope to be been clear.
#5

[eluser]theprodigy[/eluser]
I don't think this can be done via Routes. There's no clear separation as to what page would go to category, and what would go to products.
I don't believe there is any amount of regex that can separate the two for you (unless you know every category will contain the word 'cars', and not a single product will).
You might want to keep category in the url. If a user bookmarks 'http://www.mydomain.com/ferrari-403.html', and goes back to it later, how does the server know whether he/she was looking at a red ferrari or a black one? Same with porche. Porche's come in different colors. How is the server to know what color to show them?

Maybe combine
http://www.mydomain.com/red-cars-4.html with http://www.mydomain.com/ferrari-403.html
and create
http://www.mydomain.com/red-cars-4/ferrari-403.html

That tells the server everything it needs: a red Ferrari 403 car. And if the 4 is actually pagination (red-cars-1, red-cars-2, etc) it also keeps the page number they were on, but back linking to the category page Wink




Theme © iAndrew 2016 - Forum software by © MyBB