We have a website where many of the urls are created dynamically from the database. If a user adds a new article or something, a url is generated containing the id of the article in the querystring so that it can be pulled up. The article doesn't exist as a physical page in DNN, its displayed using the id value in the url.
Now we need the urls to not have the id but rather just the title. This is for SEO purposes. So instead of: https://www.website.com/n...3/t/todays-headlines
it needs to be: https://www.website.com/news/todays-headlines
We presently have modified things so that the following url will work to successfully pull up the article: https://www.website.com/news/t/todays-headlines
But this one does not: https://www.website.com/news/todays-headlines
It redirects to: https://www.website.com/news
How do we get the url to retain the page title eventhough its not in a querystring key / value pair? We're using the razor host to generate the page content from the url.
If you were using OpenContent this would be taken care of for you. I use it for my company blog where /blog is the list page and /blog/{slug} is the detail page. Example: https://celestify.com/blo...site-from-ransomware
Specific to your case however, a UrlRewrite rule will do the job just fine. First make sure to install the UrlRewrite extension in IIS (direct link). Once you have that in place, you can use a rewrite rule in your web.config in the block as follows:
Link to code snippet: https://gist.github.com/p...4026a68fe77b9366367f
I've just tested this with a Razor host module in a DNN 9.9.1 instance, seems to do the trick. Hope it works for you!
Thanks so much for your help! I'm trying to stick to the core offerings and not use 3rd party stuff unless necessary. I tried this solution but it didn't quite do the trick. I've been playing around with the idea though. I think that we may go with creating a custom URL extension provider. Thanks again for your help!
I would assume that OP has a backend mechanism that ensures the so-called "slug" e.g. "todays-headlines" is unique and automatically handles new entries with the same name by appending something to it, e.g "todays-headlines-2". Generally though website.com/news/{id}/{slug} is an easier approach and also achieved with a UrlRewrite rule in web.config.
Ps. UrlRewrite is an official (Microsoft maintained) IIS extension in case OP is worried about third party support.
I've experienced this exact issue before where url params are ignored and the page gets redirected. Depending on your DNN version there are several ways to fix this, but they take some time to troubleshoot and test, there's no one-click fix unfortunately.
If you're running DNN 9.x, you can probably use the "Do Not Rewrite URL Regular Expression" option, under the "Expressions" tab to ignore the /news path from being rewritten by DNN. You'll find this under Persona Bar > Cog icon > SEO > URL Management.
Then you can use the Test URL tab to check whether it works. Worth pointing out that you may need to clear the cache in between, depending on how heavily your site is being cached.
Hope this helps.
These Forums are for the discussion of the open source CMS DNN platform and ecosystem.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.