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

I need to redirect**YYY**


I tried all I found online but the only things that works is redirect directory_one/index.php to newpage.php without parameters.

I tried this .htaccess

RewriteCond %{HTTP_HOST} [NC]
RewriteCond %{QUERY_STRING} ^(param_one=XXX&param_two=**YYY**)
RewriteRule ^$ [R=301,L]

only to see if somethings happens but not works

I tried also

RewriteCond %{REQUEST_URI} /directory_one/index\.php
RewriteCond %{QUERY_STRING} param_one=XXX&param_two=**YYY**
RewriteRule ^(.*)$ [L,R=301]

but nothings happened

share|improve this question

Make sure you have AllowOverride set for the directory .htaccess resides in or Apache will ignore it.

Try this:

RewriteCond %{QUERY_STRING} param_one=XXX
RewriteCond %{QUERY_STRING} param_two=([^&]+)
RewriteRule ^/directory_one/index\.php$ [L,R]

If param_two really is to be YYY, use this as there is no need to use backreferences:

RewriteCond %{QUERY_STRING} param_one=XXX
RewriteCond %{QUERY_STRING} param_two=YYY
RewriteRule ^/directory_one/index\.php$ [L,R]

If none of the above work, another rule might take precedence or you may have placed the rules in the wrong spot. You should debug the whole thing with

RewriteLog /path/to/file.log
RewriteLogLevel 3
share|improve this answer
it doesn't work...;-( this is what I wrote: RewriteEngine On RewriteCond %{QUERY_STRING} main_page=product_info RewriteCond %{QUERY_STRING} products_id=([^&]+) RewriteRule ^/shop/index\.php$ [L,R] nothing happens..... sorry but I can not indent the code properly – Luciano Michelini Sep 10 '13 at 12:14
Try specifying the full url,, in the RewriteRule line. I just tested this in Apache/2.2.22 (Ubuntu), it works like a charm. – fuero Sep 10 '13 at 12:23
I used the full url, the last line was: RewriteRule ^/shop/index\.php$ [L,R] – Luciano Michelini Sep 10 '13 at 12:32
i put the http but not appears – Luciano Michelini Sep 10 '13 at 12:33
I'm using Apache/2.2.14 (Unix) – Luciano Michelini Sep 10 '13 at 12:38

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.