Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I get mod_rewrite to match a rule just once
    primarykey
    data
    text
    <p>I have the following URL...</p> <p><a href="http://localhost/http.mygarble.com/foundationsofwebprogramming/86">http://localhost/http.mygarble.com/foundationsofwebprogramming/86</a></p> <p>...that I want to convert into the following:</p> <p><a href="http://localhost/http.mygarble.com/php/blog.php?subdomain=foundationsofwebprogramming&amp;page=posts&amp;label=86">http://localhost/http.mygarble.com/php/blog.php?subdomain=foundationsofwebprogramming&amp;page=posts&amp;label=86</a></p> <p>I thought I could achieve this with the following rule:</p> <pre><code>RewriteRule ([^/]+)/([^/]+)$ php/blog.php?subdomain=$1&amp;page=post&amp;label=$2 [NC,L] </code></pre> <p>However what I find is that this rule is applied repeatedly, resulting in an internal server error. I understand that when the URI is transformed using this rule, the resulting URI will also match the rule, and therefore it is applied again ad-infinitum.</p> <p>My previous (admittedly rather hazy) understanding was that the [L] flag would stop further processing, although I now understand that this simply means that only the remainder of the rules are skipped, and does not stop the rewrite engine running through the rules again.</p> <p>I can fix this problem by adding the following condition...</p> <pre><code>RewriteCond $0 !php/blog.php RewriteRule ([^/]+)/([^/]+)$ php/blog.php?subdomain=$1&amp;page=post&amp;label=$2 [NC,L] </code></pre> <p>...or by writing a more specific regular expression. But what I really want to do is find a way of stopping the rewrite engine from attempting ANY further matches once this rule is matched once. Is this possible?</p> <p>Many thanks.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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