I'm having a problem, or better to say a doubt about how to do.
Let's explain: I have an website similar to a blog where I write articles and they are displayed in the homepage. I want that every time I click on an article it redirects me to the page where the article's content is shown. I save every article in a database with the title, date, content, etc... My doubt is: should I create a .html file for each article or only a file called "article.php" and when I open it, it changes the content getting the data from the database?
Second question: I want that the url of the page changes based of article that I click. For example I click on the article called "Today and Tomorrow", I want that the URL appears as "mysite/today-and-tomorrow/", not "mysite/article.php". I'm a bit confused about this topic so if anyone can help me i'd be very happy. Thanks in advice.
I have tried
var link = 'www.example.com/training/product.html';
link.split('.html')[0];
window.history.replaceState( null, null, link );
But it changes the URL dinamically, so for a few seconds it appears the original URL, in my case it appears "mysite/article.php" and then it changes in "mysite/today-and-tomorrow". I don't think it's properly correct.
I also tried
function openArticle(title){
var rightTitle = $(title).text();
rightTitle = rightTitle.toLowerCase();
rightTitle = rightTitle.substring(rightTitle .indexOf(':')+2);
rightTitle = rightTitle.replace(/[^A-Z0-9]+/ig, "-");
event.preventDefault();
window.location.href = title.href + "/" + rightTitle;
}
But when I click on the element the "article.php" remains in the url