At the moment I use the following code to convert dynamic URLs to static in my .htaccess file:
RewriteRule ^([a-z0-9_\-]+)$ /index.php?page=$1 [L,NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?page=([^&]+)\ HTTP/
RewriteRule ^index\.php$ http://www.mywebsite.com/%1? [R=301,L]
What I’d like to know is if it’s possible to change this rule so that pages can be access via www.mywebsite.com/news but also additional $_GET information can appended like so: www.mywebsite.com/news?id=1
You want to take a look at the QSA flag, which will append query strings after you constructed one:
This makes it so a request for
http://www.mywebsite.com/news?id=1gets internally rewritten to:/index.php?page=news&id=1