Now the client wants the query to be a custom URL. So I have to get the query and return a URL which should be like below. And this URL should also return the original Query to the system when hit from Google.
sys/denmark/viborg/webdevelopers
Obviously there is no content page which match the url, its a fake URL based on querystrings.
Any way to do this i Umbraco? I think it would be possible with general Routing in general ASP MVC.
You can set up a custom route, in the App_Start is where all your routing takes place.
The way I handled this was using javascript to add to the URL but not refresh the page, then a controller that got the results and then parsed this in JSON.
Then on page load (incase the user landed on the page with teh URL already changed to ys/denmark/viborg/webdevelopers then run this a return the results automatically!
For example, this works perfectly when the name of location here portion is hard coded but I'm struggling without to pass that as a match anything into the action.
Hi
I have a similar problem. I'm trying to use iis url rewrite to overwrite the following address: ..../pobocky?filter=test on .../pobocky/test
I have a rule set:
Query string to URL structure
Hi there guys.
I was hoping, someone could give me a hint or clue on how to solve a problem.
In Umbraco I have a custom controller, where I query the controller with:
Now the client wants the query to be a custom URL. So I have to get the query and return a URL which should be like below. And this URL should also return the original Query to the system when hit from Google.
Obviously there is no content page which match the url, its a fake URL based on querystrings.
Any way to do this i Umbraco? I think it would be possible with general Routing in general ASP MVC.
/Cheers Peter
You can set up a custom route, in the App_Start is where all your routing takes place.
The way I handled this was using javascript to add to the URL but not refresh the page, then a controller that got the results and then parsed this in JSON.
Then on page load (incase the user landed on the page with teh URL already changed to y
s/denmark/viborg/webdevelopers
then run this a return the results automatically!Thanks, Lewis
Hi Lewis,
Thats a very good suggestion. It would work. I also found some documentation on URLrewrite which I believe is supported in Umbraco.
https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
Thanks for pointing me in the right direction.
Did you ever find a rewrite rule that actually does this? Most of what's out there seems to do it the other way around.
Hi Amir,
Yes, it was quite easy to do with the IIS URL rewrite module wizard (SEO friendly URL).
I.e. this snippet redirects /database?type=booktags to /database/booktags and Umbraco still works without a problem.
Interesting, do you know how you might do it if /database was a variable portion of the url like the name of a location?
For example, this works perfectly when the name of location here portion is hard coded but I'm struggling without to pass that as a match anything into the action.
I am not 100% sure, but I think that
Means "anything". Those IIS redirects can be really hard to figure out.
So maybe:
I can see the problem, cause you need to assign the /name-of-location, somehow to a variable.
I would go to https://forums.iis.net/ and ask them there.
Hi Peter
Although IIS Rewrite rules does the job, I would recommend you to take a look at custom MVC routes defined in Umbraco instead: https://our.umbraco.com/Documentation/Reference/Routing/custom-routes
Hi Søren
Ok, I will give it a try this weekend. :-)
Cheers. /Peter
Hi Søren, why is custom routes preferred?
Hi I have a similar problem. I'm trying to use iis url rewrite to overwrite the following address: ..../pobocky?filter=test on .../pobocky/test I have a rule set:
but I still get 404. What am I doing wrong Thanks
Hi Pavel, something like this should work for your needs. Its the variation in location name that's giving us issues.
Pasting isn't working for some reason so here's a screengrab.
is working on a reply...