URL Rewrite Control
URL Rewrite Control
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
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
-
- Commodore (COMO)
- Posts: 433
- Joined: Wed May 28, 2008 9:42 am
- Location: Concord, NC
- Contact:
Re: URL Rewrite Control
I am looking for this except specifically product pages.
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: URL Rewrite Control
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
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
Re: URL Rewrite Control
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?
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?
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: URL Rewrite Control
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
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
Re: URL Rewrite Control
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?
Re: URL Rewrite Control
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.
Re: URL Rewrite Control
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
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
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: URL Rewrite Control
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
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
Re: URL Rewrite Control
Is there a way to have urls without the -c123.aspx suffixes, so that inbound links are protected when the catalog numbers change ?