Just wondering if anyone has had any luck removing the ?alttemplate=templatename part of the url using the url rewriting module but keeping the new (alt) template inplace?
So for our mobile sites we redirect to a m. subdomain and then add alttemplate=Mobile-Home to the end. What i'd like is so that when someone's on the mobile subdomain then it'll strip the alttemplate bit from the url, keeping them clean.
So far i've only got it to redirect to the alttemplate-less page but i can't get it to just strip/rewrite the end. It will only work if i have the redirect="Application" line in the rewrite rule.
This would remove the "altTemplate" querystring from the URL, but would require you to include an extra URL segment for the template's suffix; (whereas the template's prefix is "Mobile-").
Not entirely sure that it will work, but it's worth a try.
This works in that it rewrites the url properly, problem is i've got a load of different mobile alttemplates and no way of getting their names from the rest of the url.
As you know, both of these are equivalent and produce the same result:
I know this solution was made a while ago but have a quick question.
I like the idea of the /mobile-home.aspx or /mobile-home, but it there a way to write that so when the page comes up it adds something like http://localhost/mobile/mypage, but the mobile home template is chosen.
I have no idea if this will even work.
OR is there another way to get the URL or to get Umbraco to have the ability to do something like http://localhost/mypage and the same content show up on the http://localhost/mobile/mypage, without having to duplicate content?
I was using the URL rewriting in UMBRACO 4.7.2 on my custom Global.asax file into the Application_BeginRequest method. Now I'm trying to upgrade to version 6.0.0 where I saw that I have to change my custom Global.asax to inherit from Umbraco.Web.UmbracoApplication.
No problems so far in general in the application, but when the global.asax triggers the HttpContext.Current.RewritePath(URL), after migrating to version 6, the method does not rewrite the URL at all. It does not give any error or exception, it simply doesn't rewrite the URL, and consequently the system returns 404 , file not found.
Any ideas about it? Did the version 6 of Umbraco stop to support the HttpContext.Current.RewritePath method in its new Global.asax?
I chose the HttpContext.Current.RewritePath solution in the Global.asax because of the particular customised situation. I also have to show long titles (with possible bad characters to replace) in the rewritten address... I thought the web.config solution was a better way to rewrite URLs in more "static" cases, where you can simply map ADDRESS x -> ADDRESS y, with a more limited set of combinations..but I could be wrong...
No logs in "umbraco\App_Data\Logs" folder about this issue.
In general, as you said, I don't know if the RewritePath is the best solution (maybe not) but it worked till version 4.9.0 of Umbraco. Only since the Global.asax has to inherit from Umbraco.Web.UmbracoApplication instead of HttpApplication it stopped working...this is strange...
I am not sure if this helps but here is some documenation about the application start up Event Handler and some of the changes that occured from 4.9 to 4.10 and to 6.0+ You might want to take a look at this. I am not sure if this is causing anything on your end, which is may be, but it looks like in 4.10 ApplicationStartupHandler and moved the implementation of an IApplicationEventHandler
I have a feeling this is because of the MVC approach Umbraco moved to. I have a feeling the links below may help you out..
alttemplate -> url rewriting
Just wondering if anyone has had any luck removing the ?alttemplate=templatename part of the url using the url rewriting module but keeping the new (alt) template inplace?
So for our mobile sites we redirect to a m. subdomain and then add alttemplate=Mobile-Home to the end. What i'd like is so that when someone's on the mobile subdomain then it'll strip the alttemplate bit from the url, keeping them clean.
So far i've only got it to redirect to the alttemplate-less page but i can't get it to just strip/rewrite the end. It will only work if i have the redirect="Application" line in the rewrite rule.
Anyone have any ideas or know if this is possible or not?
Cheers.
Hi Rory,
Try changing the "rewriteUrlParameter" parameter value to "ExcludeFromClientQueryString"?
Cheers, Lee.
Hi Lee,
I've tried that but doing so send's it into a redirect loop. If i take out the redirect line from the rule then the whole thing stops working..
Cheers.
Hi Rory,
I haven't tested this, but thinking that you might want to try re-working the rewrite rule to something like this:
This would remove the "altTemplate" querystring from the URL, but would require you to include an extra URL segment for the template's suffix; (whereas the template's prefix is "Mobile-").
Not entirely sure that it will work, but it's worth a try.
Cheers, Lee.
Quick hack... use extensionless urls and then you can just slap the template name on the end!
As you know, both of these are equivalent and produce the same result:
The difficulty is inserting the template alias before the .aspx portion of the url.
BUT... if you use exentionless urls with umbraco you don't have to do that and your life is much simpler:
cheers,
doug.
Quick follow on from Doug's suggestion... if you can't use extensionless URLs (for whatever reason), then you could try this:
The only "gotcha" is if you have multiple ".aspx" strings in the URL (can't think of a reason why, but it's possible - maybe a subdomain?)
Cheers guys, only just got around to looking into this again.
This works in that it rewrites the url properly, problem is i've got a load of different mobile alttemplates and no way of getting their names from the rest of the url.
As you know, both of these are equivalent and produce the same result:
I didn't but i do now :) This is really good actually. Should be able to ge this working i think as we have extension-less url's set up.
Nice one.
I know this solution was made a while ago but have a quick question.
I like the idea of the /mobile-home.aspx or /mobile-home, but it there a way to write that so when the page comes up it adds something like http://localhost/mobile/mypage, but the mobile home template is chosen.
I have no idea if this will even work.
OR is there another way to get the URL or to get Umbraco to have the ability to do something like http://localhost/mypage and the same content show up on the http://localhost/mobile/mypage, without having to duplicate content?
I hope I explained my question correctly.
Thanks
Hi all,
I was using the URL rewriting in UMBRACO 4.7.2 on my custom Global.asax file into the Application_BeginRequest method. Now I'm trying to upgrade to version 6.0.0 where I saw that I have to change my custom Global.asax to inherit from Umbraco.Web.UmbracoApplication.
No problems so far in general in the application, but when the global.asax triggers the HttpContext.Current.RewritePath(URL), after migrating to version 6, the method does not rewrite the URL at all. It does not give any error or exception, it simply doesn't rewrite the URL, and consequently the system returns 404 , file not found.
Any ideas about it? Did the version 6 of Umbraco stop to support the HttpContext.Current.RewritePath method in its new Global.asax?
Thanks in advance to all of you!
@Davide,
May I ask why you would be doing this in the Global.asax and not in the Web.config?
Is there anything in your logs that states an issue, even if you are not getting an exeption the logs might let you know of an issue.
Hi and thanks for your reply!
I chose the HttpContext.Current.RewritePath solution in the Global.asax because of the particular customised situation. I also have to show long titles (with possible bad characters to replace) in the rewritten address... I thought the web.config solution was a better way to rewrite URLs in more "static" cases, where you can simply map ADDRESS x -> ADDRESS y, with a more limited set of combinations..but I could be wrong...
No logs in "umbraco\App_Data\Logs" folder about this issue.
In general, as you said, I don't know if the RewritePath is the best solution (maybe not) but it worked till version 4.9.0 of Umbraco. Only since the Global.asax has to inherit from Umbraco.Web.UmbracoApplication instead of HttpApplication it stopped working...this is strange...
Hi Davide,
I am not sure if this helps but here is some documenation about the application start up Event Handler and some of the changes that occured from 4.9 to 4.10 and to 6.0+ You might want to take a look at this. I am not sure if this is causing anything on your end, which is may be, but it looks like in 4.10 ApplicationStartupHandler and moved the implementation of an IApplicationEventHandler
I have a feeling this is because of the MVC approach Umbraco moved to. I have a feeling the links below may help you out..
http://our.umbraco.org/documentation/Reference/Mvc/using-ioc
http://our.umbraco.org/documentation/Reference/Events/application-startup
http://our.umbraco.org/wiki/reference/api-cheatsheet/using-iapplicationeventhandler-to-register-events
Here is one from Stack overflow talking about a few of the new methods for the Global.asax
.http://stackoverflow.com/questions/15872770/global-asax-in-umbraco-6
is working on a reply...