I imagine this is a problem with a fairly simple solution to anyone who's proficient with the syntax of .htaccess files, but unfortunately that I am not.
I've worked out how to make it so that when someone accesses domain.com/something/5
then internally it acts as though they accessed domain.com/something/?page=5
. However, as it is, the user can still access the "ugly" URL if they choose to, and apparently it's bad SEO-wise to have two different URLs with exactly the same content. So, I'd like to force users to use the clean URL.
Here's my .htaccess file:
RewriteEngine On
RewriteRule ^\?page=([0-9]+)$ index.php?page=$1 [R=301,NC,L]
RewriteRule ^([0-9]+)/?$ index.php?page=$1 [NC,L]
Of course, the bottom isn't really relevant to the question as it's the rule that internally redirects clean URLs to the dirty ones, but I thought I'd better include it anyway.
I've gone over it probably a dozen times searching for a mistake in the regex, as well as just hopefully removing things like the caret and the Dollar sign, but still nothing happens when I access it via ?page=5
.
Any ideas on how I can do this?