Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to have this URL rewritten as follow:

  • »
  • »
  • »

for these, I have the following mod_rewrite rules on a .htaccess file

  • subdomain + tag

    RewriteCond %{HTTP_HOST} ^([^.]+) [NC]

    RewriteRule ^tag/([^/]+) catch.php?country=%1&tag=$1 [L,NS]

  • tag

    RewriteRule ^tag/([^/]+) catch.php?tag=$1 [L,NS]

  • subdomain

    RewriteCond %{HTTP_HOST} ^([^.]+) [NC]

    RewriteRule ^(.*)$ catch.php?country=%1 [L,NS]

in this order exactly.

Now, the L after the first RewriteRule should end processing and redirect it to the subdomain+tag URL, but it doesn't. For example, is sent to catch.php?country=fr, which is the last condition in the .htaccess file.

Shouldn't it stop after the first L found?

thanks in advance, cheers


well, it turns out that the [L] flag works differently depending on the context (.htaccess/<directory> different from httpd.conf) as you can see here.

So, to make it work just place the rules inside the <VirtualHost> (NOT <Directory>) and add a '/' to every URI (/catch.php, /tag, ...). That's it.

share|improve this question
up vote 1 down vote accepted

The L flag won't stop processing under all circumstances. I'd suggest checking out this thread on Stack Overflow, especially the link to the Apache Rewrite Guide, and also turning on the RewriteLog so that you can confirm how mod_rewrite is processing your rules.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.