I'm working with friendly URLs in a site developed in PHP. I created the .htaccess file and made the necessary redirects according to my needs. For example, the page namesite.com/contact.php is now as nomedosite.com/contact. So far so good. Now I have a page called noticias.php that brings various news to the user. When clicking on a certain news, it is called the file demostraanoticia.php? Id = 2 (for example id of news item 2) and the news is displayed. I want to make when clicking on the news, her url is nomedosite.com/mostranoticia/selected-name-n4/4. How can I create a rule for this and how is the link in the href="" from my code?
My question is the syntax of the regular expression and how to make the name stay in the url, since I have the name saved in the database and the name of the news has spaces between the words and in the url I can not have these spaces.