Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5964857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:30:32+00:00 2026-05-22T19:30:32+00:00

I would like to ask a question in order to understand how Apache processes

  • 0

I would like to ask a question in order to understand how Apache processes rewrite rules specified in the .htaccess file.

On my site I used a classical organization of the pages in categories, each category having more than one section:

http://www.mysite.com/category/section.html.

However, there are no html pages, everything is processed by the code in pages.php. Using a simple rewrite rule, URLs like the one above are mapped onto:

http://www.mysite.com/pages.php?cat=category&page=section

I decided to rename a section from section1 to section1-xxx. In order to serve requests for the old name (section1), I added a simple rule to map section1.html on section1-xxx.html.

The first rules I added in the .htaccess were the following:

R1

RewriteRule ^CAT1/section1.html$ CAT1/section1-xxx.html [NC]

where CAT1 is the name of a category.

R2

RewriteRule ^CAT1/(.*).html$ pages.php?cat=CAT1&page=$1 [L,NC]

My idea was to apply R1 and then R2. However, when those rules are applied, I end up with an unexplainable (for my brain) URL.

When the following page is requested

http://www.mysite.com/CAT1/section1.html

the URL is first transformed in

http://www.mysite.com/CAT1/section1-xxx.html/section1.html

then in

http://www.mysite.com/pages.php?cat=CAT1&page=section1-xxx.html/section1

Out of curiosity, I added the L (flag) to rule R1:

RewriteRule ^CAT1/section1.html$ CAT1/section1-xxx.html [L,NC]

and everything worked fine. Now http://www.mysite.com/CAT1/section1.html is served via:

http://www.mysite.com/pages.php?cat=CAT1&page=section1-xxx

Now the questions:

  1. Why did I get that URL before adding the L flag to rule R1?
  2. The L flag should indicate to apply the matching rule and then stop using other rules. However, with the L flag set, both R1 and R2 are applied. Why?

Thanks for your time.

Regards,
A.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:30:33+00:00Added an answer on May 22, 2026 at 7:30 pm

    The [L] flag can have unexpected results if we are not clear on how the module behaves. Note that the following only applies when mod_rewrite is used in a .htaccess file. The [L] flag behaves exactly as expected when used in httpd.conf.

    The L flag will tell Apache to stop processing the rewrite rules for that request. Now what is often unrealised is that it now makes a new request for the new, rewritten filename and begin processing the rewrite rules again.

    Therefore, if you were to do a rewrite where the destination is still a match to the pattern, it will not behave as desired. In these cases, you should use a RewriteCond to exlude a certain file from the rule.

    As you explained add L to R1.(R1 redirects something.html to someone.html ie you nedd html page their!)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just like Carl's question over here I would like to ask you (because I
I would like to ask a rather, general, high-level introductory kind of question regarding
I know this is a weird question to ask, but I would like to
The question I would like to ask is if the Javascript snippet below is
I would like to ask a question regarding a strange behavior I face using
I would like to ask couple of Questions regarding the use of Monitor Class
I would like ask if there's a way to download an android layout from
What I would like ask is best illustrated by an example, so bear with
I would like to ask for some simple examples showing the uses of <div>
I would like to ask you which automated build environment you consider better, based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.