 <p>You will have to create a rule for each possible situation, with 2 parameters, 1 parameter and no parameters.</p> <pre><code>RewriteEngine On RewriteRule ^([^/]*)/parameter1/([^/]*)/parameter2/([^/]*)(/?)$ $1.php? parameter1=$2&amp;parameter2=$3 [NC] RewriteRule ^([^/]*)/parameter1/([^/]*)(/?)$ $1.php?parameter1=$2 [NC] RewriteRule ^([^/]*)(/?)$ $1.php [NC] </code></pre> <p>The (/?) at the end is to also catch the situations where the link ends with a possible slash.</p>