Creating Custom User Friendly URL's

I am trying to workout a custom URL requirement. We are a product based website, and url to each product is like




https://www.domainname.com/product/index/id/product_id



Now i want the urls to be user friendly and something like this…




https://www.domainname.com/productcustomurl



To achieve this i have created a field named custom_url in the table product where the customurl will be stored by product creator during the product creation. For this i have created a rule in the params.php like this:




'<controller:\w+>/<id:\d+>' => '<controller>/view',

'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',

'<controller:\w+>/<action:\w+>' => '<controller>/<action>',

'<id:(.*?)>' => 'product/index' //this rule



assuming this will redirect user whenever anyone hits


https://www.domainname.com/productcustomurl

with productcustomurl in parameter id, which is working fine, but the problem is this is redirecting each and everything to the product/index overriding all the other routes like site or user etc etc, which is an issue. I want them to be working. How do i achieve it, without affecting the normal routes of the website?? Please help.

[color="#008000"][EDIT @softark]

Added "code" tags for readability.

[/EDIT][/color]

Just a guess. I think that ‘id’ should be numeric:




'<id:\d+>' => 'product/index'

no, this isn’t solving the problem, url can be anything and not only id like example.com/productcap, example.com/newshirt etc…

i am really struggling at this…i found a solution using the db check, using some extension but then this is increasing the server response time by huge margin…almost by 6-7secs…which is a big issue.

Hi

I have the same problem with URL’s as you. Did you solve it? I get 404 using if I browse to mydomain.com/pagecustomurl

It works for me




'<url:.*?>' => 'site/index',



May this can be helpful for you. yii-sluggable-behavior