I am making a simple CMS, so the page links are domain/index.php?page=1
and so on (page2, page3...), and I am pulling the content out of the database with the following line:
$q = "SELECT name, content FROM pages WHERE page_id=$page";
That all works, but I wanted to change the look of the URLs, so I did with the following in .htaccess
RewriteRule ^([A-Za-z]+)/?$ index.php?page=$1 [NC,L]
The problem is, now when I click on the page I changed the url (in this case it was ?page=2), I don't pull the content out of the db, I guess because the MySQL query cant find $page
How do I remedy this?
EDIT:
I updated the rule to include numeric characters as well but it is still the same.
RewriteRule ^([A-Za-z0-9]+)/?$ index.php?page=$1 [NC,L]
EDIT2:
Just to hammer the point home, if I for example hardcode page=2
in the rewrite rule it works, but obviously I want that to happen dynamically. In this case $1
should become 2
.