Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This should be simple and I've looked at a number of existing questions but I still can't fix my problem. I guess I just can't wrap my head around how RewriteRule and RedirectMatch work.

I get a whole lot of server requests such as this one:

Ideally I would like to permanently redirect all these different pages to the same minus the ?iframe and following bit.

What's the best way, or the different ways to do this?

share|improve this question
up vote 2 down vote accepted

Add the following to the virtual host section which you want:

RewriteEngine on
RewriteCond %{QUERY_STRING} iframe=
RewriteRule (.*) /$1? [R=301,L]
  • The first line enable the rewrite engine
  • The second line check if query string include iframe=
  • The $1 in the third line is back reference to the request. The question mark to remove the query string. R=301 force a redirect with 301 status, L means last rule.
share|improve this answer
This works great. Thanks quanta. And thanks for the clear explanations too. – allesklar Sep 17 '11 at 15:42
RewriteCond %{QUERY_STRING} iframe=
RewriteRule (.*)$1? [R=301]

Try that. You'll need to put it in each article folder in a .htaccess file, since each article folder has a different URL.

share|improve this answer
This is a Rails DB app so they are no really folders in there. Can I put this rule, or any other rule, in the Apache vhost? Also I need a rule for all such pages I cannot create a new rewrite rule every time the user will add a record to these pages. Thanks for your guidance. – allesklar Sep 17 '11 at 14:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.