Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Edit: Misunderstood the question.</p> <p>You want to rewrite /projects/project-name/ to index.php?... I am also assuming you'll want to be able to request files from within project-name:</p> <pre><code>RewriteEngine on RewriteRule ^([^/]+)/([^/]+)(/(index[^/]+)?)?$ /index.php?section=$1&amp;item=$2 [QSA,NC,L] </code></pre> <p>If being able to request files from the project-name subdir isn't important, just remove <code>(/(index[^/]+)?)</code> and replace it with <code>/</code>. The <code>(/(index[^/]+)?)</code> assumes your <code>DirectoryIndex</code> files start with "index".</p> <p>Meh.</p> <p>Consider enabling the mod_rewrite log to analyze how it is applying your conditions and patterns. Within the server or vhost scope (not htaccess) add:</p> <pre><code>LogLevel warn rewrite:trace6 </code></pre> <p>The <a href="http://httpd.apache.org/docs/current/mod/core.html#loglevel" rel="nofollow"><code>LogLevel</code></a> directive can <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html#logging" rel="nofollow">enable logging for mod_rewrite</a> which will be written to your defined <code>ErrorLog</code>. trace6 is the highest mod_rewrite log level before you get into hex output. Be sure to comment out or remove LogLevel when you're done.</p> <hr> <p>Original, unrelated answer (ignore):</p> <p>You need to negate files, of which right now you are not, notice the use of <code>!</code>:</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-f </code></pre> <p>Most importantly, your <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond" rel="nofollow">RewriteCond</a> will not affect your second RewriteRule. It is only applied to the first RewriteRule (in your case <code>RewriteRule . - [L]</code>):</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/([^/]+)/?$ index.php?section=$1&amp;item=$2&amp;%{QUERY_STRING} [NC,L] </code></pre> <p>And you may also choose to negate directories:</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-d </code></pre> <p>I'd also consider using the <a href="http://httpd.apache.org/docs/current/rewrite/flags.html#flag_qsa" rel="nofollow"><code>QSA</code> (query string append)</a> flag instead of appending <code>QUERY_STRING</code>:</p> <pre><code>RewriteRule ^([^/]+)/([^/]+)/?$ index.php?section=$1&amp;item=$2 [QSA,NC,L] </code></pre> <p>In summary:</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/?$ index.php?section=$1&amp;item=$2 [QSA,NC,L] </code></pre>
 

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