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:http://www.yogacentersc.es/paginas/38-titulados-por-aipys?iframe=true&width=80%&height=80%

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?

2 Answers 2


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.
  • This works great. Thanks quanta. And thanks for the clear explanations too.
    – allesklar
    Sep 17, 2011 at 15:42
RewriteCond %{QUERY_STRING} iframe=
RewriteRule (.*) http://www.website.com/article-name-numbers/$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.

  • 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, 2011 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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