appending query string with Sitecore URL Rewrite module - url-rewriting

I am trying to rewrite incoming URL requests with the Sitecore URL Rewrite module in Sitecore 9. The request come in with the format of www.site.com/find-location/locations/1111 but the current service requires the format to be www.site.com/find-location/locations/?id=1111. I have tried applying the query string of "id=1111" to the Sitecore link and selecting Append query string in the redirect item but the query string is never applied. The inbound rule works correctly as I can set it to point to a specific page without a query string and it will redirect to that page but will not apply a query string. Is there something that I am missing or is there a better way to accomplish this?

I found the solution by setting the redirect link as an external link and giving it the query string ?id={R:1} which is the matched pattern.

Related

Changing domains in IIS environment

I am working with IIS (Internet Information Services ) in a windows server with URL Rewrite.
Need to redirect a URL (https://page.olddomain.com) to a new URL (https://page.newdomain.com). Everything remains the same, just need to URL to change if a user goes to https://page.olddomain.com.
Wondering if I'm following the right process of thought here.
I have a Inbound Rule created that should work.
Match URL
Requested URL: Matches the Pattern Using: Exact Match Pattern:
https ://page.olddomain.com (ignore case)
No conditions set
No server variables
Action
Action Type: Rewrite
Action Properties
Rewrite URL: https://page.newdomain.com
Append query string: checked
Am I missing anything here?
For this problem, if you can't implement the redirect step, I think it was caused by the wrong input in Pattern box which same with the comment mentioned by Lex Li.
We do not need to input the base url(such as https://page.olddomain.com) in Pattern, we just need to input the append url after the base url in Pattern. For your requirement, you just need to do it as below screenshot:
I suggest you to use "Regular Expressions" instead of "Exact Match", it can success implement your requirement.
And by the way, maybe you want to input / in Pattern(just ignore baseurl), but it will not work. So please input .* in Pattern. Apart from this, you'd better also define a condition to specify the HTTP_HOST equal your old host url.
For the comment you mentioned about SSL, I think it will not be affected by the redirect/rewrite rule.

Is there a DNN URL decode method as it is changing a URL Encode

We are using Server.URLEncode to change an SKU with a forward slash from BDF5555/45 to BD5555%2F45 in our Href on a button.
When a person clicks on the button the page navigates to another module which has Request.QueryString but DNN is changing the URL.
How can I get the variable decodeprodCode to include the &45 as BDF5555/45?
Perhaps DNN is rewriting the URL?
There is a NavigateURL class in DotNetNuke.Common.Globals that will generate a correct url based on a TabID and a lot of overloads.
DotNetNuke.Common.Globals.NavigateURL(TabId)
You can also use querystring parameters
DotNetNuke.Common.Globals.NavigateURL(TabId, ControlKey,"key=value"))
DNN by default will re-write querystring values into /key/value format in the URL assuming that it is properly encoded. For example if you have querystring values of sku=1 and productid = 2 the resultant URL will be
https://yoursite.com/Your-Page/sku/1/productid/2
This is done via the FriendlyUrlProvider, but it should not have any impact to your ability to process via Request.Querystring as this is a very, very common practice for passing values into DNN.
Your code to retrieve the value is correct.
I ended up using the following code instead of a Request.Querystring.
string RawurlFromRequest = Request.RawUrl;
var cleanSKU = RawurlFromRequest.Split(new[] {"sku/"}, StringSplitOptions.None)[1];
var CleanSKUNoOtherQueryStrings = cleanSKU.Split(new[] {"&"}, StringSplitOptions.None)[0];
The Request.RawURL brings back the URL with the special characters as it is without encoding. As Mitchel Sellers mentioned above, DNN uses the FriendlyURLProvider which rewrites the URL.
For example www.mysite.com/ProductFilter/SKU/BDF5555/45 and not
www.mysite.com/ProductFilter/SKU/BDF5555%2F45
The CleanSKU variable will look for SKU/ and split everything on the left as it is set to [1].
After everything has been split on the left, we look for other QueryStrings which we usually add with a & sign. We will split everything on the right by setting it to [0].
This will bring back BDF5555/45 in the backend with a forward slash which we can use to retrieve product information from our ERP system which URLdecode couldn't do.

Google Analytics: Exclude URL Query Parameters when using URL rewrite

I need to exclude some parameters to aggregate properly the pages of my website. I know there is "Exclude URL Query Parameters" and that's OK.
The problem is when I use the URL rewrite. Example.
I have tried with a custom filter for renaming URLs, but it seems to be ignored.
Can anyone help me with the correct syntax?
Please, see this screenshot:
I doubt any of your URIs start with "fbphoto" (^fbphoto). "/fbphoto" is more likely (^/fbphoto)
If the intent is to rewrite all photo URLs with /fbphoto/, here's the syntax to use:
Search String:
^/fbphoto.*
Replace String:
/fbphoto/

Magento - passing params in URL to template file

I have a template file at ../page/video.phtml and it's served at http://mysite/video.
I want to add params in the url to play different videos on that page. I can add it as a query string param, http://mysite/video?select=filename but I would prefer to use http://mysite/video/filename.
However, when I try this I get a 404. What would I have to do to achieve this?
I'm using Magento 1.7
You must explicitly include all the action parts (route, controller and action) in the URL before adding parameters this way, because when you use http://mysite/video/filename, Magento looks for the index action of the filename controller for the module having a front route named video (which does not exist, hence the 404 error).
From the URL you gave, a working URL would rather look like this : http://mysite/video/index/index/select/filename

Ajax results filtering and URL parameters

I am building a results filtering page using AJAX requests. I would like to reflect the filters in the URL. For example: for price_from I want to add ?price_from=VAL to the URL.
I have a backend that is capable of rendering the page with URL parameters.
After some googling I would a Backbone.router solution which has a hash fallback for the IE that does not support HTML5 history API.
I have a problem with setting a good philosophy of routes. I have a set of filtering parameters (price_from, price_to, color, ...) and I would like to attach each parameter to one route.
Is that possible to chain the routes to match for example: ?price_from=0&price_to=1&color=red? (the item order can change)
It means: call all the routes at the same time and keep the ie backwards compatibility?
Your best bet would be to have a query portion of the URL rather than using GET parameters to denote the search criteria. For example:
Push state: /search/query/price_from=0&price_to=1&color=red
Hash based: #search/query/price_from=0&price_to=1&color=red
Your backend would of course need to change a bit to be able to parse the new URL structure.

Resources