title: htaccess seo-friendly URL's
body: <p>I need some help to get friendly URL's on my website. </p>
  
  <p>These are my links i need to rewrite:</p>
  
  <pre><code>www.example.com/index.php?page=pagename
  www.example.com/index.php?page=profile&amp;id=number
  </code></pre>
  
  <p>This is my .htaccess. I solved the issue for the first link, however I can't do it for the second one.</p>
  
  <p>I would like to have for the second link:</p>
  
  <pre><code>www.example.com/profile/name or
  www.example.com/profile/id
  </code></pre>
  
  <p>This is my .htaccess file:</p>
  
  <pre><code># for www.example.com/index.php?page=profile&amp;id=number
  RewriteCond %{THE_REQUEST} \?page=([^&amp;]+)&amp;id=([0-9]+)
  RewriteRule ^ /%1/%2? [L,R=301]
  
  # for www.example.com/index.php?page=page
  RewriteCond %{THE_REQUEST} \?page=([^&amp;\ ]+)($|\ )
  RewriteRule ^ /%1? [L,R=301]
  
  # rewrites back
  RewriteCond %{REQUEST_FILENAME} !-d 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^([^/]+)/([0-9]+)$ /index.php?page=$1&amp;id=$2 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^([^/]+)$ /index.php?page=$1 [L]
  </code></pre>
  
  <p>The code I submitted above solved my problem.</p>