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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:46:30+00:00 2026-06-07T20:46:30+00:00

I have this in my .htaccess file RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f

  • 0

I have this in my .htaccess file

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

What I am trying to do is add another RewriteRule to this configuration so that old URLs like these will be redirected to the root of the site

http://www.acme.com/category.php?id=6
http://www.acme.com/product.php?id=183&category= 

I know that “category.php” and “product.php” will now be a invalid strings. Using “category.php” as an example I tried altering the config to be this

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^category.php(.*) / [L,R=301]
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

This will redirect as follows

http://www.acme.com/category.php?id=112 -> http://www.acme.com/?id=112

I have two problems

  1. I don’t want the query string to be appended. I haven’t specified
    [QSA]
  2. If I enter the root directly www.acme.com the page won’t display
    unless I remove the line I just added. Why would my new RewriteRule
    affect URL’s that dont start with “category.php”?

[Edit]

I have also tried this instead of the redirect above, but I still seem to be getting both rules being applied

RewriteRule ^category.php /holdingPage.php [L]
  • 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-07T20:46:33+00:00Added an answer on June 7, 2026 at 8:46 pm

    You need the 2 conditions to be tied to the old rule that sends everything through index.php and you need to add your new rule above them:

    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^category.php /? [L,R=301]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
    

    To deal with 1., I’ve added a “?” at the end of the / in the rule’s target. That makes it so query strings won’t automatically get appended unless you specifically have the QSA flag. As for 2., not sure why it wasn’t working for you, but it may have had something to do with the 2 conditions that were being applied to the wrong rule.


    EDIT:

    For a description of the 2 RewriteCond lines, see this post: https://stackoverflow.com/a/11275339/851273

    A RewriteCond is essentially a conditional, this block:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
    

    is essentially this (in pseudo code):

    if(request_uri != maps_to_existing file) {
        if(request_uri != maps_to_existing_directory) {
            request_uri = request_uri.replace("([^?]*)", "index.php?_route_=$1", "[L,QSA]");
        }
    }
    

    The thing is, a RewriteCond, or many of them one directly after another, only applies to the immediately following RewriteRule, so without moving the category.php rule out in front, the pseudoc deo equivalent would have been:

    if(request_uri != maps_to_existing file) {
        if(request_uri != maps_to_existing_directory) {
            request_uri = request_uri.replace("^category.php", "/?", "[L,R=301]");
        }
    }
    request_uri = request_uri.replace("([^?]*)", "index.php?_route_=$1", "[L,QSA]");
    

    Which is kind of broken because the 2 if() conditionals are being mis-applied. Specifically the one that rewrites to “index.php” sort of requires the conditionals in order to prevent itself from looping.

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

Sidebar

Related Questions

I have got this .htaccess file: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond
I have a .htaccess file: RewriteEngine On DirectoryIndex control.php Options +FollowSymlinks RewriteBase / RewriteCond
I have the htaccess file Options -Indexes +FollowSymlinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME}
I have the folllowing .htaccess file RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond
I currently have a .htaccess file set up with this rule: RewriteRule ^([a-zA-Z0-9_-]+)$ user\.php?user=$1
I have this htaccess rule to redirect my page to data_parser.php RewriteEngine On RewriteRule
I have this code in my .htaccess: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule
Currently my .htaccess looks like this... Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME}
I have the following mod_rewrite within my .htaccess file: RewriteEngine On RewriteBase / RewriteCond
My current .htaccess file contains the following lines: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule

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.