Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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 (.*) 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.

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

 
discard

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.