Redirect links using .htaccess file

0

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?

tr ust

Posted 2018-01-12T19:03:21.230

Reputation: 1

Setup rewrite rules. For examples see .htaccess rewrite to redirect root URL to subdirectory on SO

– Seth – 2018-01-12T19:06:24.580

please help me. – tr ust – 2018-01-12T19:11:33.583

No. What have you actually tried? Did you read the apache documentation on mod_rewrite? Did you even try to come up with rewrite rules that match your problem? Please spend some time to read how to ask a good question.

– Seth – 2018-01-12T19:13:34.550

Answers

0

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

Gerard H. Pille

Posted 2018-01-12T19:03:21.230

Reputation: 542

it doesnt work( – tr ust – 2018-01-12T19:59:06.120

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 – 2018-01-12T20:17:27.603

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 – 2018-01-12T21:27:14.973