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 8720465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:02:50+00:00 2026-06-13T07:02:50+00:00

So I have two rules. Each rule does exactly what it should when its

  • 0

So I have two rules. Each rule does exactly what it should when its in the .htaccess by itself, but when both rules are there they start to conflict with each other.

RewriteCond %{REQUEST_URI} ^(.*)\.html$
RewriteRule ^(.*)\.html$ index.php?id=$1 [QSA,L]

The above rule works fine for getting say http://domain.com/12.html and passing the number 12 into index.php only if the number finishes with .html (note 12.html file does not exist!)

RewriteCond %{REQUEST_URI} !^(.*)\.html$
RewriteRule ^(.*)$ /$1\.html [L,R=301]

This works fine for checking if the URL ends with .html. And if it DOES NOT finish with .html, it will redirect it to the URI + .html (this also works fine by itself).

When I have both rules in the one .htaccess

RewriteCond %{REQUEST_URI} ^(.*)\.html$
RewriteRule ^(.*)\.html$ index.php?id=$1 [QSA,L]

RewriteCond %{REQUEST_URI} !^(.*)\.html$
RewriteRule ^(.*)$ /$1\.html [L,R=301]

then there is a loop resulting in a redirect loop.

Can someone please point out where I am going wrong?

  • 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-13T07:02:51+00:00Added an answer on June 13, 2026 at 7:02 am

    So, the first rule rewrites http://domain.com/12.html into http://domain.com/index.php?id=12. Then things start going awry; the second rule rewrites that into http://domain.com/index.php.html?id=12, but at that point I think you’ll find that the first rule kicks in again, rewriting that into something like http://domain.com/index.php?id=index.php, which the second rule rewrites into http://domain.com/index.php.html?id=index.php. At this point I think the rules end up fighting over the URL.

    The easiest solution is probably to tweak the second rewrite rule not to rewrite pages that already contain an extension, i.e. use [^.]* instead of .*.

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

Sidebar

Related Questions

I have two CSS rules following each other: .some td:first-child:before { content:url('path/to/image.png') ; }
We have a rules processing system where each rule is represented by a class
I have two columns say Main and Sub . (they can be of same
I have two main problems with mod_rewrite: There is no meaningful error reported when
I have two issues I have ignored so far, but I will really appreciate
I have a rules engine, which supports two modes of operations: Compilation into a
I have a need to mod-rewrite my domain based off of subdomains...there are two
I have two ordered lists of the same element type, each list having at
There is a general rule of OO design that you should model is-a relationships
I have seen following CSS rule at two website /* First example */ background:

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.