DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Include Page Title in URL but not as a Querystring value

 8 Replies
 2 Subscribed to this topic
 40 Subscribed to this forum
Sort:
Author
Messages
New Around Here
Posts: 6
New Around Here

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.

New Around Here
Posts: 19
New Around Here

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!

 

Paras Daryanani

Celestify

Celestify - we build digital ecosystems.
New Around Here
Posts: 6
New Around Here

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!

Growing Member
Posts: 51
Growing Member
I'm not sure that I like this approach. I think the ID maybe needs to be there as well.

I can see how it could work for the example of "Today's News", Each day there is a new Today's News page. I'm more concerned when you get TWO articles both with the title "Man Bites Dog".

I was once involved with a web site that listed films. Eventually we hit exactly this problem of ambiguous titles.
New Around Here
Posts: 19
New Around Here

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.

Paras Daryanani

Celestify

Celestify - we build digital ecosystems.
New Around Here
Posts: 6
New Around Here
Hi Richard, yes your concern is valid. Paras is correct in that we will have logic in place that will ensure unique slugs.

The reason for the avoidance of 3rd party modules whenever possible is that we had a vendor, whose modules we were heavily reliant on, change their pricing structure to something that was not feasible for us.

It's been much better to just use the core offerings when possible and so far that's been working out well for us. Razor offers a lot of flexibility.

I do wish the IIS option had worked as that would be simpler than creating our own extension provider but there seems to be something in DNN that is overriding the rewrite rule somehow. Which takes precedence, DNN's rewrites or IIS's?

Even with the IIS rule in place, this:
https://www.website.com/news/todays-headlines

Still goes to this:
https://www.website.com/news

It drops the slug if it isn't included in the url as a key value pair like this:
https://www.website.com/news/t/todays-headlines

But that's not what we want. We just need it to be https://www.website.com/news/todays-headlines
New Around Here
Posts: 19
New Around Here

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 "

Paras Daryanani

Celestify

Celestify - we build digital ecosystems.
New Around Here
Posts: 6
New Around Here
Thanks Paras,

Gave that a try but it resulted in a 404. I noticed on one of our other websites, which is on a different host, that what I'm trying to do works there. So it is a setting that's preventing us from accomplishing this easily. I'll have to keep poking around and comparing the configuration for this portal to the other one and see what the difference is.
New Around Here
Posts: 3
New Around Here
Hi All,

Greetings of the day.

Have anyone find out any resolution of the reported issue. Same type of issue i am facing on one portal. I want to pass title in URL to load different Articles, blogs, reports etc. though title instead of passing Ids in URL as parameter, to improve SEO Analytics. This functionality is working properly on one another Portal, where i am able to pass Article, blog title in URL and functionality work as expected. But in same EVOQ Basic (v. 09.13.07) instance have created another parent portal and try to pass title in URL but that auto redirected to actual page and remove the Title from URL (due to Rewriting Result). Have tried with multiple options & configuration changes but no luck. If any suggestion or solution please help.

Regards,
Himanshu

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:

  1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
  2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
  3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  5. No Flaming or Trolling.
  6. No Profanity, Racism, or Prejudice.
  7. Site Moderators have the final word on approving / removing a thread or post or comment.
  8. English language posting only, please.

Would you like to help us?

Awesome! Simply post in the forums using the link below and we'll get you started.

Get Involved