Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# If it's a real file or
RewriteCond %{SCRIPT_FILENAME} -d [OR]
# a real directory
RewriteCond %{SCRIPT_FILENAME} -f
# do nothing
RewriteRule ^index\.php$ - [QSA,L]
# Changes /index.php?page=welcome to /
RewriteRule ^$ /index.php?page=welcome [QSA,L]
# Changes /index.php?page=blabla to /blabla
RewriteRule ^([^/]+)$ /index.php?page=$1 [QSA,L]
It will only redirect to www if I have a $page. For example... http://example.com/blah will go to http://www.example.com/blah but http://example.com/ won't redirect