URL Rewrite Control

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
TTMedia
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 83
Joined: Mon Dec 03, 2007 11:49 am

URL Rewrite Control

Post by TTMedia » Tue Jul 28, 2009 10:21 am

Hello,

I would like to have more control of the URL name of each page. Right now, the URL is created through the Product or Category Name field and I am wanting to see if it is possible to create a new field, and point the URL capture to that field.

The product and category naming and anchor text will all the same as the Name Field, but the new URL field will control what the page URL is and the link associated with the anchor text.

I don't mind the -c123.aspx suffixes, but would like to implement some more keyword rich URL's for certain products.

Thanks

Robbie@FireFold
Commodore (COMO)
Commodore (COMO)
Posts: 433
Joined: Wed May 28, 2008 9:42 am
Location: Concord, NC
Contact:

Re: URL Rewrite Control

Post by Robbie@FireFold » Tue Jul 28, 2009 12:10 pm

I am looking for this except specifically product pages.
Robbie Hodge
General Manager
Robbie@FireFold.com
http://www.FireFold.com

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: URL Rewrite Control

Post by jmestep » Tue Jul 28, 2009 2:51 pm

You can try something like this, only P instead of W and pull your custom page name from somewhere. The important thing is getting the C, P, W numbers and letters in the proper place right before the .aspx

Code: Select all

HyperLink HyperLinkAlias = (HyperLink)e.Item.FindControl("HyperLinkAlias");
            HyperLinkAlias.NavigateUrl = "~/" + Regex.Replace(StringHelper.CleanupSpecialChars(_TopicAlias), "[:!;+@ ]", "-") + "-W" + _Topic.CatalogNodeId + "C" + _Topic.CategoryId + ".aspx" + "?CatId=" + CategoryId.ToString() + "&ProdId=" + ProductId.ToString();
            HyperLinkAlias.Text = _TopicAlias;
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

TTMedia
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 83
Joined: Mon Dec 03, 2007 11:49 am

Re: URL Rewrite Control

Post by TTMedia » Wed Jul 29, 2009 10:12 am

Thank you,

So if I create a new field in the database and place this field in the category and product add/edit catalog backend, I can use the code to create my own custom URL's?

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: URL Rewrite Control

Post by jmestep » Wed Jul 29, 2009 10:59 am

Yes, just reference that field, then follow the pattern for what I did with _TopicAlias- I turned the spaces into - and stripped out some other characters. You can actually see something like that work in the url- just go to a product page and put any text you want before the -Pxx.aspx. It will still go to the same page.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

zxcjason
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Wed Jul 29, 2009 3:56 pm

Re: URL Rewrite Control

Post by zxcjason » Wed Jul 29, 2009 4:05 pm

I'm wondering if there is a way to modify the NavigateUrl property of the product class, if not I suppose I'll have to add the code for each link I want to customize?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: URL Rewrite Control

Post by mazhar » Thu Jul 30, 2009 3:41 am

You can't modify NavigateUrl property. Alternatively you can write your custom function that can take Navigate Url value and process it to your desired format.

markpuck
Ensign (ENS)
Ensign (ENS)
Posts: 10
Joined: Mon Aug 03, 2009 11:30 pm

Re: URL Rewrite Control

Post by markpuck » Wed Aug 05, 2009 1:53 pm

I love that you can override the text in the url!

Can anybody tell me about the ~ that is stuffed into NavigateUrl? Why is it there?

If I try to use NavigateUrl with a straight <a href it keeps the ~ in the url, as in ~Foo-C10.apx, so the url doesn't work. But using the asp:Hyperlink the ~ gets stripped off.

Thanks

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: URL Rewrite Control

Post by jmestep » Wed Aug 05, 2009 2:09 pm

The ~ in a <asp:hyperlink points means to use the url in relation to the root of the site. For example, if you put code in your header for a link to search.aspx and you don't do ~/search.aspx, when that header is on a checkout page the link won't work because the checkout pages are in a Checkout folder under the root of the site.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

bl108
Ensign (ENS)
Ensign (ENS)
Posts: 3
Joined: Sat Aug 15, 2009 12:51 am

Re: URL Rewrite Control

Post by bl108 » Sat Aug 15, 2009 12:58 am

Is there a way to have urls without the -c123.aspx suffixes, so that inbound links are protected when the catalog numbers change ?

Post Reply