Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I didn't check why the rule in your question doesn't work as expected, but you may try this instead:</p> <pre><code>RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} ^/([^/]+)/?([^/]*)?/?([^/]*)?/?([^/]*)?/? RewriteRule .* edit.php?key1=%1&amp;key2=%2&amp;key3=%3&amp;key4=%4 [L] </code></pre> <p>Maps silently:</p> <p><code>http://example.com/val1/</code> up to </p> <p><code>http://example.com/val1/val2/val3/val4/</code> with or without trailing slashes</p> <p>To:</p> <p><code>http://example.com/edit.php?key1=val1&amp;key2=val2&amp;key3=val3&amp;key4=val4</code></p> <p>The maximum quantity of <code>valN</code> values passed in the incoming URL, is 4. The minimum is 1. That range can be adjusted modifying the rule, though.</p> <p>When any <code>valN</code> is not present in the incoming URL, the value in the corresponding key-value pair in the query added to the substitution URL, will be empty.</p> <p>However, the <code>key</code> will always be present in the query as all <code>keys</code> are fixed strings not passed by the incoming URL.</p> <p>This rule-set is tested and working and it should be tested without any other rule that might get in conflict with it. I didn't check the other rules in the question and can't say if they work or if they could affect this one. That was not part of the question.</p> <h3>UPDATE</h3> <p><strong>Redirecting to edit.php:</strong></p> <p>Mapping to edit.php is required only when there are 3 or 4 folders in the URL-path.</p> <p>The modified rule-set is:</p> <pre><code>RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !edit\.php [NC] RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)/([^/]+)/?([^/]*)?/?$ [NC] RewriteRule .* edit.php?key1=%1&amp;key2=%2&amp;key3=%3&amp;key4=%4 [L,QSA] </code></pre> <p>Maps silently:</p> <p><code>http://example.com/val1/val2/val3/</code> up to</p> <p><code>http://example.com/val1/val2/val3/val4/</code> with or without trailing slashes</p> <p>To:</p> <p><code>http://example.com/edit.php?key1=val1&amp;key2=val2&amp;key3=val3&amp;key4=val4</code></p> <p>The maximum quantity of valN values passed in the incoming URL, is 4. The minimum is 3.</p> <hr> <p><strong>Redirecting to content.php:</strong></p> <p>Mapping to content.php is very similar to the previous one, except is done only when the number of folders is 1 or 2.</p> <p>So the rule-set is basically the same with less regex groups:</p> <pre><code>RewriteCond %{REQUEST_URI} !content\.php [NC] RewriteCond %{REQUEST_URI} ^/([^/]+)/?([^/]*)?/?$ [NC] RewriteRule .* content.php?key1=%1&amp;key2=%2 [L,QSA] </code></pre> <p>Maps silently:</p> <p><code>http://example.com/val1/</code> up to</p> <p><code>http://example.com/val1/val2/</code> with or without trailing slashes</p> <p>To:</p> <p><code>http://example.com/content.php?key1=val1&amp;key2=val2</code></p> <p>The maximum quantity of valN values passed in the incoming URL, is 2. The minimum is 1.</p> <p>The <strong>complete rule-set</strong> is like this:</p> <pre><code>Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !edit\.php [NC] RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)/([^/]+)/?([^/]*)?/?$ [NC] RewriteRule .* edit.php?key1=%1&amp;key2=%2&amp;key3=%3&amp;key4=%4 [L,QSA] RewriteCond %{REQUEST_URI} !content\.php [NC] RewriteCond %{REQUEST_URI} ^/([^/]+)/?([^/]*)?/?$ [NC] RewriteRule .* content.php?key1=%1&amp;key2=%2 [L,QSA] </code></pre> <p>Hope I understood what you want.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload