g1smd - 8:18 pm on Jun 6, 2010 (gmt 0)
Yes, that would work, but - and this is the kicker - just because you have a script at
/index.php and calling it with parameters like
/index.php?p=234 displays the various pages, there is no need for the
/index.php or the
?p=234 part to appear in the URL in *that* form.
Indeed, you're better off changing the HTML code so that site links to, and uses, URLs like
example.com/p234 and then also re-arranging the rewrite code so that the rewrite internally calls the script at
/index.php?page=234 without revealing that location to the outside world.
# Rewrite URL request for example.com/p<num> to script at /index.php?page=<num>
RewriteRule ^p([0-9]+)$ /index.php?page=$1 [L]
The good news is that there are literally thousands of prior threads with similar requirements and
.htaccess code examples right here in this forum.
Finally, your script will return the numbered page requested. It will return the "index" page when no page number is specified. When a non-valid page number is requested, the script MUST return the HTTP 404 header, and an error message. This last point is VITAL.