I have a site (not live yet) that serves articles with PHP using parameters in the query string, like this: I would like to turn that URL into I know I can use .htaccess to rewrite the URL like so: Or something like that... I don't know the regex too well. My question is... won't rewriting that URL just redirect the end user's browser to /the-title, which doesn't exist? How do I do it correctly? And can it be done without writing a new rewriterule for each article?
I'm using this on my site: Options +FollowSymLinks RewriteEngine on RewriteRule ^thetitle-([0-9]*) article.php?id=$1 [NC] Code (markup): When you go to http://localhost/thetitle-123/ you will see content of http://localhost/article.php?id=123
That's wild! Thanks! And Google will index the-title? If it works just like it looks, then only apache knows the article.php url? If so, this clears up my confusion as to why the full URL was used when using .htaccess for redirect, even though it appeared only the filename from the request was coming in. With this method, it looks like anyone could put /anyoldthing-3 and get duplicate content for thetitle-3. Still I quest!