title: .htaccess to beautify a url
body: <p>There are several articles about this but I cannot make it work.<br />
  I have the following urls:</p>
  <pre><code> 1. /index.php
   2. /index.php?lg=el
   3. /index.php?lg=en
   4. /index.php?lg=el#anchor
   5. /index.php?lg=en#anchor
   6. /index.php?ct=1&amp;lg=el
   7. /index.php?ct=1&amp;lg=el#anchor
   8. /index.php?ct=1&amp;lg=en
   9. /index.php?ct=1&amp;lg=en#anchor
  10. /index.php?ct=2&amp;lg=el
  11. /index.php?ct=2&amp;lg=el#anchor
  12. /index.php?ct=3&amp;lg=el
  13. /index.php?ct=3&amp;lg=el#anchor
  14. /index.php?ct=4&amp;lg=el
  15. /index.php?ct=4&amp;lg=el#anchor
  16. /index.php?ct=5&amp;lg=el
  17. /index.php?ct=5&amp;lg=el#anchor
  18. /index.php?ct=2&amp;lg=en
  19. /index.php?ct=2&amp;lg=en#anchor
  20. /index.php?ct=3&amp;lg=en
  21. /index.php?ct=3&amp;lg=en#anchor
  22. /index.php?ct=4&amp;lg=en
  23. /index.php?ct=4&amp;lg=en#anchor
  24. /index.php?ct=5&amp;lg=en
  25. /index.php?ct=5&amp;lg=en#anchor
  </code></pre>
  <p>and similar ones without the &quot;index.php&quot;.
  The &quot;ct&quot; variable should be converted based on the following array (index from 1):</p>
  <pre><code>[company,history,news,measurements,contact]
  </code></pre>
  <p>I want to convert them to:</p>
  <pre><code> 1. /
   2. /el
   3. /en
   4. /el#anchor
   5. /en#anchor
   6. /el/company
   7. /el/company#anchor
   8. /en/company
   9. /en/company#anchor
  10. /el/history
  11. /el/history#anchor
  12. /el/news
  13. /el/news#anchor
  14. /el/measurements
  15. /el/measurements#anchor
  16. /el/contact
  17. /el/contact#anchor
  18. /en/history
  19. /en/history#anchor
  20. /en/news
  21. /en/news#anchor
  22. /en/measurements
  23. /en/measurements#anchor
  24. /en/contact
  25. /en/contact#anchor
  </code></pre>
  <p>I have tried the following syntax in .htaccess:</p>
  <pre><code>RewriteEngine on
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(\/)?([a-z]{2})?(\/)?((?:company|history|news|measurements|contact))?(#[\w\-]+)?$ $1index.php?ct=$4&amp;lg=$2$5 [L,QSA]
  </code></pre>
  <p>but I cannot get the expected result.<br />
  Any ideas?</p>