Reference capture groups of multiple RewriteCond in RewriteRule

You could try constructing the target URL inside the rewrite conditions: RewriteCond ##%{QUERY_STRING} (.*)##(|.*&)param1=([^&]+) RewriteCond %1/%3##%{QUERY_STRING} (.*)##(|.*&)param2=([^&]+) RewriteCond %1/%3##%{QUERY_STRING} (.*)##(|.*&)param3=([^&]+) RewriteCond %1/%3##%{QUERY_STRING} (.*)##(|.*&)param4=([^&]+) RewriteCond %1/%3##%{QUERY_STRING} (.*)##(|.*&)param5=([^&]+) RewriteCond %1/%3##%{QUERY_STRING} (.*)##(|.*&)param6=([^&]+) RewriteRule ^foo$ /bar%1/%3? [L,R] When I try to request: /foo?param1=a&param2=b&param6=3&param3=4&param5=5&param4=6 I get redirected to: /bar/a/b/4/6/5/3 Adding any additional required query string parameters won’t make it look … Read more

using header() to rewrite filename in URL for dynamic pdf

Try: header(‘Content-Disposition: attachment; filename=”July Report.pdf”‘); or header(‘Content-Disposition: inline; filename=”July Report.pdf”‘); Another option would be to use the $_SERVER[‘PATH_INFO’] to pass your “July Report.pdf” – an example link might be: <a href=”https://stackoverflow.com/questions/2015985/report_pdf.php/July%20Report.pdf?month=07″> That file should default to saving as “July Report.pdf” – and should behave exactly like your old php script did, just change the code … Read more

Redirect all traffic to root of another domain

From http://www.webconfs.com/how-to-redirect-a-webpage.php I’d say you can use the following configuration Don’t redirect subfolders/files (as you wanted): www.example.com/demo/ -> www.newexampledomain.com Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/ [R=301,L] Redirect to subfolders/files: www.example.com/demo/ -> www.newexampledomain.com/demo/ Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]