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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:09:27+00:00 2026-05-11T05:09:27+00:00

I’m trying to get all HTML and PHP files on my site to redirect

  • 0

I’m trying to get all HTML and PHP files on my site to redirect through the index.php, so that they can have common frames applied to them, a templating solution I coded that I found to be quite elegant. Anywho, I’m having issues with my PHP files, specifically those that have arguments after them.

My regular rule for PHP files is the following:

RewriteCond %{REQUEST_URI} !index.php$ RewriteRule ^(.+).php$ index.php?page=$1&type=1 [NC,L] 

This works fine for any pages that have no arguments, but you can see that any PHP documents that have

?argument=something 

end up as:

index.php?page=path/to/page?argument=something&type=1 

which is not a working solution at all. Now, what’s bothering me here is the $ at the end of the rule, shouldn’t that cause it to fail if there is anything after the .php?

Anywho, I tried rewriting the rule as:

RewriteRule ^(.+).php\?(.+)$ index.php?page=$1&type=1&$2 [NC,L] 

but that simply doesn’t trigger at all. It seems that the regex flavor used in mod_rewrite is far different than I’m used to working with, so I’m sure these are simple mistakes I’ve made, but I can’t seem to find decent documentation for this flavor of regex other than the most basic of examples.

Can anyone show me what I’m doing wrong? Thanks.

  • 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. 2026-05-11T05:09:28+00:00Added an answer on May 11, 2026 at 5:09 am

    Try qsa in your rule, which stands for ‘query string append’ – mod_rewrite will then append any query string from the original URL to the rewritten URL

    RewriteCond %{REQUEST_URI} !index.php$ RewriteRule ^(.+).php$ index.php?page=$1&type=1 [NC,L,qsa] 

    RewriteRule doesn’t match against the query string, which is why your second attempt did not work. Here’s the relevant note from the manual

    The Pattern will not be matched against the query string. Instead, you must use a RewriteCond with the %{QUERY_STRING} variable. You can, however, create URLs in the substitution string, containing a query string part. Simply use a question mark inside the substitution string, to indicate that the following text should be re-injected into the query string. When you want to erase an existing query string, end the substitution string with just a question mark. To combine a new query string with an old one, use the [QSA] flag.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.