If the query string was something like page.aspx?something=/something/something/something would it still work? If umbracoUseDirectoryUrls are turned on the in the web.config, will that cause an issue? Are there any other config changes that need to be made? Will the rewritten URL be linkable and crawlable for search/seo?
You should be able to use the built-in UrlRewriting library to achieve this, by adding a rule to the config file @ /config/urlRewriting.config. There's an example there that should get you started. Did you already try this and are having problems?
Directory URLs shouldn't matter since you're using a querystring.
The rewritten URL should be linkable and crawlable, but it's up to you to add links to it in the right format across your pages.
Thanks for the help. I've been trying to tweak the example in the file without any luck. Are you able to provide an example for me to try? Thanks again!
If I type in my address ... /healthlibrary.aspx?test=blah, nothing happens. I've tried adding a comment to the web.config and did an iisreset. I toggled the umbracoUseDirectoryUrls true false as well for the heck of it. Thoughts? Thanks again!
When you say nothing happens, are you getting a 404 or a blank page or something else?
If you're not able to get to your destination URL that sounds like another issue. If you comment out the new rule, can you then get to the /healthlibrary.aspx?test=xxxx URL? If so, what URL are you using to test?
Hi Tom, it is working. I was just expecting it to redirect to the friendly URL, but that's not what the rewrite does. The more I though about it, the directory URLs still allow the .aspx. I'm not getting a 404 anymore, so it is working.
Is there an easy way to automatically redirect the query string to the friendly URL? Thanks for your help.
Hmm, not sure about that. You could possibly add another rewrite rule that matches the querystring version of the URL and does a Redirect (not a rewrite) to the "clean" version, but not sure if that will end up in an infinite loop. You might also be able to put some code on your page that somehow detects you're on the querystring version and redirects, not too sure if that will work though.
I don't think it's an issue as long as you link to the "clean" version in all your code. Or are you worried users already have links to the querystring version?
Query string to friendly URL rewrite rule
Hi
I'm having some issues with a URL rewrite rule. I've searched the forums/web and found similar posts, but I am not able to get this working.
We need a rule to make query strings like this: http://www.mysite.com/page.aspx?something=something
To something like this automatically: http://www.mysite.com/page/something/something
If the query string was something like page.aspx?something=/something/something/something would it still work? If umbracoUseDirectoryUrls are turned on the in the web.config, will that cause an issue? Are there any other config changes that need to be made? Will the rewritten URL be linkable and crawlable for search/seo?
Thanks for your help!
Hi Ryan,
You should be able to use the built-in UrlRewriting library to achieve this, by adding a rule to the config file @ /config/urlRewriting.config. There's an example there that should get you started. Did you already try this and are having problems?
Directory URLs shouldn't matter since you're using a querystring.
The rewritten URL should be linkable and crawlable, but it's up to you to add links to it in the right format across your pages.
Let us know how you get on
-Tom
Hi Tom,
Thanks for the help. I've been trying to tweak the example in the file without any luck. Are you able to provide an example for me to try? Thanks again!
I think this should work. You might need to touch your web.config in order for the change to take effect:
-Tom
If I type in my address ... /healthlibrary.aspx?test=blah, nothing happens. I've tried adding a comment to the web.config and did an iisreset. I toggled the umbracoUseDirectoryUrls true false as well for the heck of it. Thoughts? Thanks again!
When you say nothing happens, are you getting a 404 or a blank page or something else?
If you're not able to get to your destination URL that sounds like another issue. If you comment out the new rule, can you then get to the /healthlibrary.aspx?test=xxxx URL? If so, what URL are you using to test?
Hi Tom, it is working. I was just expecting it to redirect to the friendly URL, but that's not what the rewrite does. The more I though about it, the directory URLs still allow the .aspx. I'm not getting a 404 anymore, so it is working.
Is there an easy way to automatically redirect the query string to the friendly URL? Thanks for your help.
Hmm, not sure about that. You could possibly add another rewrite rule that matches the querystring version of the URL and does a Redirect (not a rewrite) to the "clean" version, but not sure if that will end up in an infinite loop. You might also be able to put some code on your page that somehow detects you're on the querystring version and redirects, not too sure if that will work though.
I don't think it's an issue as long as you link to the "clean" version in all your code. Or are you worried users already have links to the querystring version?
is working on a reply...