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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:02:08+00:00 2026-06-03T09:02:08+00:00

There are external links pointing to my site (that I have no control over)

  • 0

There are external links pointing to my site (that I have no control over) which contain bad query strings. Here is an example:

http://www.example.com/page/&query=string

The above results in a 404 page on my site. Because “http://www.example.com/page/” exists on my site, I want to use a .htaccess file to remove any bad query strings so the user can get to the correct content.

So I want this rewrite or redirect:

http://www.example.com/page/&query=string  -> http://www.example.com/page/

Any and all help is appreciated!

  • 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-03T09:02:10+00:00Added an answer on June 3, 2026 at 9:02 am

    The following should do as you said issuing a 301 redirect to the requesting browser.

    RewriteCond %{QUERY_STRING} query=string
    RewriteRule ^/page/ /page/ [R=301]
    

    However you just want to serve the right content you can avoid the 301 redirect with this:

    RewriteCond %{QUERY_STRING} query=string
    RewriteRule ^/page/ /page/ [PT,NS,E=QUERY_STRING:]
    

    It will remove the QUERY_STRING entirely so be aware.

    If you wanted to rewrite some different query strings but not all for /page/

    RewriteCond %{QUERY_STRING} query=badstring1 [OR]
    RewriteCond %{QUERY_STRING} query=badstring2 [OR]
    RewriteRule ^/page/ /page/ [PT,NS]
    

    All RewriteRules assume that you have the “RewriteEngine On” somewhere, it is possible likely that your host has this done. It will also require the mod_rewrite module in Apache which I assume is in use based on the .htaccess request.

    http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html

    That all said this seems very unnecessary as a page will ignore the arguments if it does not need them, unless of course this is being passed to a script in which case you should be able to handle this in the code, but perhaps you have a framework that is causing issues.

    This is a great book on the subject:
    Pro Apache
    See pages 277-299

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

Sidebar

Related Questions

I have a page that loads an external HTML page into an iFrame. There
I have a library that does I/O. There are a couple of external knobs
I have a website (here: http://kitandmarcin.us ) with links to a variety of external
Is there any external library using which one can edit and save XML files
I have certain PHP class methods that access external variables. These variables are not
I have a CHM help file that has a few clickable links to powerpoint
I want to process all links but external ones from the whole web site.
i have a website in joomla 1.0. it has some links to external sites
I have a script that generates a temporary HTML file that has links to
I have a web project that has a \META-INF\services\javax.servlet.ServletContainerInitializer file with its content pointing

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.