i want to achieve few redirection like
when user will type this www.mysite.com/label/uk or www.mysite.com/label.aspx/uk then my labeluk.aspx will load or
when user will type this www.mysite.com/label/us or www.mysite.com/label.aspx/us then my labelus.aspx will load or
when user will type this www.mysite.com/label/fr or www.mysite.com/label.aspx/fr then my labelfr.aspx will load.
so please tell me how do i define pattern for routing like
RouteTable.Routes.MapPageRoute("Source1", "label/{ID}", "~/labeluk.aspx");
RouteTable.Routes.MapPageRoute("Source1", "label/{ID}", "~/labelus.aspx");
i am not being able to figure out how to achieve it by routing. please help me to form the maproute. thanks
You can look into URL Rewriting on the web or SEO Urls
http://www.codeproject.com/KB/aspnet/URL-Rewriting-in-ASPNET.aspx
you could do something like this..
keep one route (in Global) as
RouteTable.Routes.MapPageRoute("Source", "label/{ID}, "~/label.aspx");
so all will resolve /label.aspx, then on label.aspx check ID param e.g.
Page.RouteData.Values.ContainsKey("ID")
and depending on whether it's uk, fr or us do
HttpContext.Current.RewritePath("/labeluk.aspx", false);
alternatively not even need to have /label.aspx just check ID param in Global and do RewritePath there
Related
Is it possible to create magic route with nette route ?
what i mean of magic route is i dont need to declare any route array on routelist... but when i type address on browser address bar such as :
http:somesite.com/product/detail/123.
it would point to presenter product -- renderDetail
(this magic route is known in other framework, and i think for some reason it would make complicated if i would type every single action/presenter redirection on routelist array)
thanks in advance.
Do you mean $router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');?
It's in the documentation: https://doc.nette.org/en/2.3/routing#toc-route.
Route from Matěj is working. You just need to type SomePresenter::actionTwoWords as some/two-words in url.
But don't construct urls by hand, use {link} macro in latte templates or Nette\Application\LinkGenerator in code.
Is there a way to open a specified document, eg "production order 123" or form, eg "purchase orders" in Ax2012 from an external application directly?
In detail, I'm looking for something similiar like AXPath, but this doesn't work with versions greater then 2009.
Is there any ( maybe included ) way to achieve this?
There is! It's using AX's drilldown functionality which uses AxHLink.exe to handle dynamics:// URLs, which are passed to the Classes\SysStartupCmd function. You could also create some custom code there if you wanted to launch the AX client executable directly.
My question I asked some while back should have a great deal of useful information in it here:
What handles dynamics:// URLs?
Some more can be found: http://technet.microsoft.com/en-us/library/aa834337.aspx
EDIT:
It sounds like you are confused or the posts weren't clear enough. I think you have 3 basic options.
Dynamics:// URLs are handled by AxHLink.exe and they only seem to handle drilldown, viewalert, and viewalertrule. So if you want to use Dynamics:// URLs, you will need to hi-jack those somehow. There is a pastbin from Jan in that other stack post.
Create a custom URI handler and event poller (lot of work) see http://axcoder.blogspot.dk/2010/10/how-to-open-form-in-running-ax-from.html
Extend SysStartupCmd and then instead of using Dynamics:// URLs, just call Ax32.exe -startupCmd directly and a parameter can be passed to your custom class.
I created simple HttpModule, all what I need is just get is valid Sitecore.Context inside but during processing I see that my Sitecore.Context is some kind of default.
I can get Sitecore user that log in to Sitecore, etc.
How to fix it ?
I assume you have a Sitecore Context, but it is null or set to the wrong site or language.
You can change the context like this:
// switch to the preferred site
Sitecore.Context.SetActiveSite("yourSiteName");
// set the preferred database
Sitecore.Context.Database = Sitecore.Configuration.Factory.GetDatabase("master");
// set the preferred language
Language language = Sitecore.Globalization.Language.Parse("en");
Sitecore.Context.SetLanguage = (language, false);
You probably also want to switch back to the original settings after your processing is done. So it is wise to "save" the original settings in a variable so you can change them back afterwards
Take a look at John West's posts on Sitecore pipelines for some background on how the context is being established.
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/All-About-Pipelines-in-the-Sitecore-ASPNET-CMS.aspx
and
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/05/Important-Pipelines-in-the-Sitecore-ASPNET-CMS.aspx
The following blog post on creating and running custom pipelines should give you an idea how to implement your own pipeline.
http://adeneys.wordpress.com/2008/08/27/creating-and-running-custom-pipelines-in-sitecore/
I am trying to rewrite a url in wordpress so that I can serve up dynamic content based on variables that are passed. I have a plug in that needs variable data passed into it. Currently I have:
http://xyzsite.com/page/?var1=something
this works fine and passes in a $_GET var. So my next step is to clean up the variable so that it looks like
http://xyzsite.com/page/something
I have done a few google searches and come accross some site that looked promising but I cannot get any of them to work. From what I have read, i need to use
add_rewrite_tag and add_rewrite_rule
After reading through the articles I have added this to my functions.php page:
add_rewrite_tag('%var1%','([^&]+)');
add_rewrite_rule('^page/([^&]+)/?','index.php?p=1141&var1=$matches[1]','top');
when i navigate to the page http://xyzsite.com/page/something i get a 404 error. When i navigate the to http://xyzsite.com/page/?var1=something it is still working fine. So it looks as if my rewrite is not registering or working correctly.
Can someone help me to achieve the above rewrite. FYI my permalink settings is set to post name if that matters at all. Thank you.
I̶'̶m̶ ̶n̶o̶t̶ ̶a̶ ̶r̶e̶g̶e̶x̶ ̶p̶r̶o̶,̶ ̶b̶u̶t̶ ̶I̶ ̶s̶u̶s̶p̶e̶c̶t̶ ̶a̶n̶ ̶i̶s̶s̶u̶e̶ ̶i̶n̶ ̶y̶o̶u̶r̶ ̶r̶e̶w̶r̶i̶t̶e̶ ̶r̶u̶l̶e̶:̶
a̶d̶d̶_̶r̶e̶w̶r̶i̶t̶e̶_̶r̶u̶l̶e̶(̶'̶^̶p̶a̶g̶e̶/̶(̶[̶^̶&̶]̶+̶)̶/̶?̶'̶,̶'̶i̶n̶d̶e̶x̶.̶p̶h̶p̶?̶p̶=̶1̶1̶4̶1̶&̶v̶a̶r̶1̶=̶$̶m̶a̶t̶c̶h̶e̶s̶[̶1̶]̶'̶,̶'̶t̶o̶p̶'̶)̶;̶
̶
̶N̶o̶t̶e̶ ̶t̶h̶e̶ ̶/̶?̶ ̶y̶o̶u̶'̶v̶e̶ ̶a̶d̶d̶e̶d̶ ̶a̶t̶ ̶t̶h̶e̶ ̶e̶n̶d̶.̶ ̶T̶h̶u̶s̶ ̶y̶o̶u̶ ̶s̶h̶o̶u̶l̶d̶ ̶a̶c̶c̶e̶s̶s̶ ̶y̶o̶u̶r̶ ̶p̶a̶g̶e̶ ̶w̶i̶t̶h̶ ̶h̶t̶t̶p̶:̶/̶/̶x̶y̶z̶s̶i̶t̶e̶.̶c̶o̶m̶/̶p̶a̶g̶e̶/̶s̶o̶m̶e̶t̶h̶i̶n̶g̶/̶?̶ ̶a̶n̶d̶ ̶n̶o̶t̶ ̶x̶y̶z̶s̶i̶t̶e̶.̶c̶o̶m̶/̶p̶a̶g̶e̶/̶s̶o̶m̶e̶t̶h̶i̶n̶g̶.̶ ̶H̶a̶v̶e̶ ̶y̶o̶u̶ ̶t̶r̶i̶e̶d̶ ̶i̶f̶ ̶t̶h̶a̶t̶ ̶w̶o̶r̶k̶s̶?̶
The stroked out text above is wrong, as Gustavo Straube pointed out in the comments. Please disregard that proposed solution.
My only last advice is to try adding a flush_rules(); after your last add_rewrite_rule, as stated in http://codex.wordpress.org/Rewrite_API/flush_rules.
Note that you should be accessing your query vars with get_query_var('var_name') instead of trying to access $_GET directly.
I am making one website about books and the user reaches the book which he/she intends by traversing though the subjects, then categories and then the subcategories.
As usual, I have made pages that use query strings like this
www.mywebsite.com/subjects.aspx?subjectid=10
The subjectid refers to one of the subjects.
The the user selected the categories and then subcategories and reaches the book.Now, everything is referred by it's id and not by it's name.
Now my question is that the Search Engines dont know how many subjeccts are there and the subject names are not understandable from the id(s).
When I tried to use Google Custom Search, and passed on the url of my website it does not go deep to the book level, instead stays on the main url www.mywebsite.com.
There are some website that I have seen have URL like this:
http://dotnetslackers.com/articles/aspnet/Implementing-Search-in-ASP-NET-with-Google-Custom-Search.aspx
Do they really create a seperate aspx page for each and every article ?
I maynot be able to make you people understand what I want coz I just started asp.net so please think that it has got to do with SEO.
If any clarification is need, please comment and will edit the question.
EDIT 1: Just when I posted this question I noted that it has also created a similar type of page:
http://stackoverflow.com/questions/5581873/seo-layout-of-the-website
Now, Is that a new folder "seo-layout-of-the-website" !
EDIT:2 SO it appears that URL Rewriting is what I need. The example given in one tutorial states that for urls like :
http://www.store.com/products.aspx?category=books
http://www.store.com/products.aspx?category=DVDs
http://www.store.com/products.aspx?category=CDs
I can redirect them to
http://www.store.com/products.aspx/Books
http://www.store.com/products.aspx/DVDs
http://www.store.com/products.aspx/CDs
But in my case, I am using Ids, so does that mean that I should use the names (subject.aspx?subjectname=abcd instead of subject.aspx?subjectid=123) ?
URL Rewriting is what you're looking for. So you could convert your URL:
www.mywebsite.com/subjects.aspx?subjectid=10
to:
www.mywebsite.com/subject/10
by adding a route to it. If you're using ASP.NET 4, you can do this easily. In your Global.asax.cs file, define the following in the Application_Start function:
using System.Web.Routing;
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapPageRoute(
"SubjectRoute",
"subject/{subjectId}",
"~/subjects.aspx"
);
}
And in subjects.aspx.cs, get the value with:
if (Page.RouteData.Values["subjectId"] != null)
{
var mySubjectId = Page.RouteData.Values["subjectId"].ToString());
}
No, they don't create new pages for SEO purpose. what most of us do is rewrite the URL rule in htaccess or apache files. I dont know how it works in asp though