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.

I need to redirect

www.URL.it/directory_one/index.php?param_one=XXX&param_two=**YYY**

to

www.URL.it/newpage.php?param_three=**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} =www.URL.it/directory_one/index.php? [NC]
RewriteCond %{QUERY_STRING} ^(param_one=XXX&param_two=**YYY**)
RewriteRule ^$ http://www.URL.it/newpage.php?%1 [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 ^(.*)$ http://www.URL.it/test/index.php? [L,R=301]

but nothings happened

share|improve this question

1 Answer 1

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$ http://www.URL.it/newpage.php?param_three=%1 [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$ http://www.URL.it/newpage.php?param_three=YYY [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$ url.it/schedafilm.php?id_film=%1 [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, http://www.url.it/..., 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$ url.it/schedafilm.php?id_film=%1 [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

 
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.