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

  • Home
  • SEARCH
  • 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 8003027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:32:37+00:00 2026-06-04T16:32:37+00:00

I’m playing with apache rewrite_mod (Apache/2.2.17 Win32) and encounter very weird behave of rewriteRule.

  • 0

I’m playing with apache rewrite_mod (Apache/2.2.17 Win32) and encounter very weird behave of rewriteRule.

My script primarily rewrite infinite filter parameters named f1 .. f<infinity> from nice url and in loop adding them as query variables, add path as query, and page number.

It works flawlessly, but if I add one another rule (last rule in script)

RewriteRule   ^(.+)\.html$                       /index.php?path=$1.html [QSA]

which is for another cases, it change execution of rewriterule at start of script.

Input URL:

http://testing.loc/some/thing/index0-f1-nice-cars-f2-planes-f3-karts-f4-bike.html

Expected result in PHP after all rewrites:

$_SERVER[QUERY_STRING] => path=some/thing/&page=0&f1=nice-cars&f2=planes&f3=karts&f4=bike
$_SERVER[SCRIPT_NAME] => /index.php

Script look like this (next part is flawlessly functional):

# from: some/thing/index0-f1-nice-cars-f2-planes-f3-karts-f4-bike.html
# to:   some/thing/index0.html?f=-f1-nice-cars-f2-planes-f3-karts-f4-bike

RewriteRule   ^(.*/?index[0-9]*)((?:-f[0-9]+-.+?)+)\.html$   /$1.html?f=$2 [QSA]

# from: some/thing/index0.html?f=-f1-nice-cars-f2-planes-f3-karts-f4-bike
# to    index.php?path=some/thing/&page=0&f=-f1-nice-cars-f2-planes-f3-karts-f4-bike

#              (   $1   )     (  $2  )
RewriteRule   ^(.+/{0,1})index([0-9]*)\.html$    /index.php?path=$1&page=$2 [QSA]

# while in f is something like "f1-nice-cars" (for example)
# remove "f1-nice-cars" from f and add as query "f1=nice-cars"

#                              (%1)    (   %2  ) ( %3)(       %4       )
RewriteCond   %{QUERY_STRING} ^(.*)&f=-(f[0-9]+)-(.+?)((?:-f[0-9]+-.+)*)$ 
RewriteRule   ^index\.php$                       /index.php?%1&%2=%3&f=%4 [L]

# remove empty "f=" from query

RewriteCond   %{QUERY_STRING} ^(.*)&f=$ 
RewriteRule   ^index\.php$                       /index.php?%1

here, after rules is url in shape:

index.php?path=some/thing/&page=0&f1=nice-cars&f2=planes&f3=karts&f4=bike

Without next rule in script is everything perfectly functional. But if I add it, this rule itself do nothing, but rewrite_mod add something more to subtitution at start of script.

# rewrite rule for other paths without filters

RewriteRule   ^(.+)\.html$                       /index.php?path=$1.html [QSA]

Actually after run all script result is:

index.php?path=/some/thing/index0.html/some/thing/index0&f1=nice-cars&f2=planes&f3=karts&f4=bike
  • 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-06-04T16:32:39+00:00Added an answer on June 4, 2026 at 4:32 pm

    I found resolution of this problem.
    When 2 rules match URL at one pass of .htaccess, then apache rewrite_mod use method “add path info postfix” (its something like bug or feature), which ruin path of request. So when I added flag [L] to that 2 rules, result is OK.

    I thinked that apache pass .htaccess sequentially and does not matter on next rules…

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.