If you go to the URL, for example: http://stackoverflow.com/questions/9155602/ , the address bar will be updated to http://stackoverflow.com/questions/9155602/redirect-existing-file-to-different-url-using-mod-rewrite . This is not done with JavaScript, but not with a hard update, I think it is done with mod_rewrite; however, how does he know the title of the article without server-side processing using php?
I just updated my site to use SEO friendly URLs, it was /shows.php?id=review-1 , and now it is /review/1/super-baseball-2020 . The text at the end doesn't really matter much when it comes to my rewriting, which:
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z0-9]+)/([0-9]+)/([a-z0-9-]+)?/?$ /shows.php?id=$1-$2 [L,NC]
My current way of making sure that Google doesn't hit me on duplicate content and that bookmarks are being sent correctly:
RewriteCond %{THE_REQUEST} ^GET\s/shows\.php\? RewriteCond %{QUERY_STRING} (?:^|&)id=review-1(?:&|$) [NC] RewriteRule ^ /review/1/super-baseball-2020/? [R=301,L,NC] RewriteCond %{THE_REQUEST} ^GET\s/shows\.php\? RewriteCond %{QUERY_STRING} (?:^|&)id=review-2(?:&|$) [NC] RewriteRule ^ /review/2/aero-fighters-2/? [R=301,L,NC] RewriteCond %{THE_REQUEST} ^GET\s/shows\.php\? RewriteCond %{QUERY_STRING} (?:^|&)id=review-3(?:&|$) [NC] RewriteRule ^ /review/3/aero-fighters-3/? [R=301,L,NC] .... and so on ....
This solution is very short-sighted, and thousands of lines fit into my .htaccess.
source share