I have a site with a lot of links that look like /click.php_id=602_from=139_to=42_url=1.html. I'd like to setup a redirect using .htaccess file(s) to have links that look like /click.php?id=602&from=139&to=42&url=1. But how would I do that?


I've never used .htaccess (don't forget to permit .htaccess to actually rewrite requests), but in Apache's conf it would be more or less like this:

RewriteRule /click.php_id=([0-9]+)_from=([0-9]+)_to=([0-9]+)_url=([0-9]+)\.html$ /click.php?id=$1&from=$2&to=$3&url=$4

you need to check my syntax, I just typed this from memory

  • it doesnt work( – tr ust Jan 12 '18 at 19:59
  • thanks a lot, all good RewriteRule ^click\.php_id=([0-9]+)_from=([0-9]+)_to=([0-9]+)_url=([0-9]+)\.html$ /click\.php?id=$1&from=$2&to=$3&url=$4 [R=301,L] its true – tr ust Jan 12 '18 at 20:17
  • I see, because a .htaccess is always in a folder, the leading slash in `/click.php' should be dropped.. One is never too old to learn. – Gerard H. Pille Jan 12 '18 at 21:27

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.