I need to redirect




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


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
  • 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
RewriteCond %{QUERY_STRING} param_one=XXX
RewriteCond %{QUERY_STRING} param_two=.*YYY.*
rewriteRule (.*) www.URL.it/newpage.php?param_three=%{QUERY_STRING} param_two

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.