We have sales rep profile pages that need to be access by firstname.lastname. So an example URL would be www.mysite.com/mark.handy. This redirect to Find-A-Rep-Detail.aspx?SalesRepWebID=mark.handy.
We're currently are buildingout at a big complicated URL Rewrite that looks at the extension and goes from there. It works, but means we need to managing this either in IIS or the web.config across multiple servers.
I'm looking at a way to do this within kentico. I know the community site has profile pages that seem to take a user's firstname.aspx and redirect to a profile page.
The kentico solution would have to check the URL and if the extension doesn't match a list (aspx, html, js, css, asmx, etc) then redirect.
Here's the kicker. Our user data isn't in kentico. we have a .asps page that has a user control that grabs the name and returns the html.
I'm looking at the wildcard URL docs: https://docs.kentico.com/k9/configuring-kentico/configuring-page-urls/wildcard-urls
Is this possible in Kentico, or should we stick with the iis/web.config options?
As the Kentico wildcard URL docs state:
If you need to allow dots in user names and use wildcard URLs with
user names at the same time, move the wildcard in the Page URL to the
middle of the URL, for example: /Members/{UserName}/Profile
If this is not an option, and the "firstname.lastname" pattern must be the last part of the URL, a possible approach would be to use the RequestEvents.Begin global event to detect the "firstname.lastname" pattern, and redirect to the appropriate page.
Assuming you are using Kentico 10:
[assembly: RegisterModule(typeof(SalesRepRedirector))]
public class SalesRepRedirector : Module
{
private static readonly Regex SalesRepRegex = new Regex(#"^\/([a-zA-Z]+\.[a-zA-Z]+)$");
public SalesRepRedirector() : base("SalesRepRedirector") { }
protected override void OnInit()
{
RequestEvents.Begin.Execute += Begin_Execute;
}
private static void Begin_Execute(object sender, EventArgs e)
{
var relativePath = RequestContext.CurrentRelativePath;
var regexMatch = SalesRepRegex.Match(relativePath);
if (regexMatch.Success)
URLHelper.Redirect("~/Find-A-Rep-Detail.aspx?SalesRepWebID=" + regexMatch.Groups[1].Value);
}
}
(Place the file in the App_Code folder, or in a separate assembly)
Some things to note:
You need to tweak the regex, to ensure that the redirection does not affect request for files and pages (.aspx, .css, .js...)
There is some overhead involved when using this approach, as every request will be checked for the pattern
I think you can accomplish this within Kentico. Note, I'm simply providing a proof of concept here and have not yet tested or created anything yet.
Add an alias to the home page (assuming this is the root of the website) so it accepts the invalid url with the username. So something like /{UsersID}. Then using the javascript webpart, you can check for the {?UsersID?} url parameter and redirect them to /Find-A-Rep page. You can even go one step further and on the Find-A-Rep page, add the same alias /Find-A-Rep/{UsersID} and then you can use a friendlier url like /Find-A-Rep/Mark.Handy and still use that querystring parameter if you need in code.
I did a quick test, it sort works but not 100% they way you want, because you cannot use "." in the wildcard URL.
You can create the template Find-A-Rep-Detail.aspx, within the template, use {? firstname ?} and {? lastname ?} to get the value.
Then in the URLs property, set a path or pattern to /{firstname}-{lastname }. If you use . instead of -, it will be replaced with -
So the wildcard URL /john-smith will be displayed by get Find-A-Rep-Detail.aspx template directly and you can get the first and last name.
One important thing for wildcard URL is the right pattern, if there is no prefix and the pattern is just /{somehting}, then your regular pages like /aboutus would be in trouble.
Hello I know this might be more of a manual approach in listing all the potential URLs, but have you considered using this URL Redirection module from Kentico - http://devnet.kentico.com/articles/url-redirection?
As you can list all your 'from' and 'to' urls all within Kentico
I want to have stack overflow like url pattern in orchard blog. How to achieve it with Auto route pattern.
For example I want to have a pattern like
/myblog/Pages/4453/what-ever-title
Here, regardless of the trailing page name (what-ever-title) I want to always point to the item 4453. I have tried following pattern but failed.
{Content.Container.Path}/Pages/{Content.Id}
{Content.Container.Path}/Pages/{Content.Id}/*
{Content.Container.Path}/Pages/{Content.Id}/{Content.Slug}
The reason I want this is that I can then change the page final url without affecting the links already being built in SEO efforts.
for instance for this question stack overflow url is
/questions/24145078/how-match-any-in-orchard-cms-auto-route
Regardsless of what I use for trailing part as long as the number 24145078 is there the url works fine.
This is not how autoroute works. Autoroute is not routing, it's generating unique paths for content items, based on token-driven rules. I you want a wildcard route, write a wildcard route.
But for this specific appliation, I'm afraid that's still not what you should do. The standard way of dealing with resources that move to a new address is to establish a permanent redirect from the old URL to the new. This is most efficiently done using the URL rewriting feature of IIS.
I get the following error below for my dynamic image generator. It can have any kind of width or height but SEO is complaining about it because it needs a canonical URL. How can I do this with a dynamic image that isnt a page?
The page with URL "http://localhost/assets/images/99?w=125" can also be accessed by using URL "http://localhost/assets/images/99?w=100".
Search engines identify unique pages by using URLs. When a single page can be accessed by using any one of multiple URLs, a search engine assumes that there are multiple unique pages. Use a single URL to reference a page to prevent dilution of page relevance. You can prevent dilution by following a standard URL format.
The canonical URL can be specified in a HTTP header, too. See RFC 6596, section 4:
or alternatively, in the HTTP header field as specified in Section 5 of [RFC5988]:
Link: <http://www.example.com/page.php?item=purse>; rel="canonical"
i have some doubt in nutch
while i used the wiki i am asked to edit the crawl-urlfilter.txt
+^http://([a-z0-9]*\.)*apache.org/
and i am asked to create an url folder and an list of url...
do i need to create all the links in crawl-urlfilter.txt and in the list of url ...
Yes and no.
crawl-urlfiler.txt act as a filter, so only urls on apache.org will ever be crawled in your example
The url folder gives the 'seed' urls where to let the crawler start.
So if you want the crawler to stay in a set of sites, you will want to make sure they have a positive match with the filter... otherwise it will crawl the entire web. This may mean you have to put the list of sites in the filter
I am using Nutch to crawl webistes and strangely for one of my webistes, the Nutch crawl returns only two urls, the home page url (http://mysite.com/) and one other.
The urls on my webiste are basically of this format
http://mysite.com/index.php?main_page=index¶ms=12
http://mysite.com/index.php?main_page=index&category=tub¶m=17
i.e. the urls differ only in terms of parameters appened to the url (the part "http://mysite.com/index.php?" is common to all urls)
Is Nutch unable to crawl such webistes?
What Nutch settings should I do in order to crawl such websites?
I got the issue fixed.
It had everything to do with the url filter set as
skip URLs containing certain characters as probable queries, etc
-[?*!#=]
I commented this filter and Nutch crawle dall urls :)