I was working on what I thought would be a simple request for a client this week – change the default URL for the Store Locator plugin for the nopCommerce platform. After a bit of digging and looking for an easy solution, I found that the plugin doesn’t support the capability to change the default URL, specifically the ‘/AllShops’ URL that will show a listing of all of the stores added to the application.
For those not familiar, nopCommerce is backed by a series of plugins from the nopTemplates group, which includes plugins such as sliders, menus, and the mentioned store locator. This store locator allows for adding a series of store locations and having them appear on Google Maps, alongside a listing of all individual stores. You can see a demo here.
Worry not, there is a simple way to make this work if you are hosting the site using IIS. First, access IIS Manager, and then access the Web Site that nopCommerce is being hosted on. Click on the ‘URL Rewrite’ option to show the current URL rerouting rules set up for the Web Site:
Once inside the URL Rewrite module, click the ‘Add Rule(s)…’ option on the right sidebar:
Click on the option to create a ‘Blank Rule’, and then add the following information:
- Name: nopCommerce Store Locator /AllShops Redirect
- Pattern: store-locator (or whatever you would like the new URL to be)
- Action URL: AllShops
After applying this change, test the change using the URL www.yourstore.com/store-locator and ensure that you are directed to the Store Locator, and the URL does not redirect to the /AllShops URL.
What this rule does is treats the ‘/store-locator’ URL as an alias for the ‘/AllShops’ URL for the Store Locator, so it would allow both URLs to point to the same place. In my case, I wanted to change the URL over, so in addition to setting up this rule, I would also need to set up a redirect to have the ‘/AllShops’ URL redirect to the ‘/store-locator’ URL. This allows for simulating a true URL change.
One caveat with the is that is you use Visual Studio to Publish the application to IIS, it will overwrite all of the URL reroute rules in place, meaning you will need to recreate this rule to make sure your alias still works.