Forum Moderators: phranque

Message Too Old, No Replies

redirect short url to a long url.

redirect short url to a long url.

         

chetanmadaan

7:33 pm on Jun 20, 2011 (gmt 0)

10+ Year Member



we have a long url which we send to users in email and sometimes they have problems clicking it. so, we want to shorten the url to something in few characters.


long url: index.php?option=vm&page=downloads&product_id=6&file_name=soft.exe&id=#*$!X

the #*$!X will be the download id per customer.

short url: www.oursite.com/pdownload?#*$!X

is there a htaccess redirect we can do here?

Thanks

g1smd

7:39 pm on Jun 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, it is one line of code if you DON'T use a parameter. Place the code quite near the beginning of your .htaccess file:

RewriteRule ^pdownload-([0-9]+)$ http://www.example.com/index.php?option=vm&page=downloads&product_id=6&file_name=soft.exe&id=$1 [R=301,L]


If you use a parameter the code is more complicated, and there's several gotcha's that will come into play.