Shortened url redirect?
Huyimin’s Question:
I need help to get this done.
My webpages have formatted urls in this pattern: “http://qifu.us/index.php?page=item&id=4” for example – if there are more pages, only the last page id number will be different.
I want to get this part “index.php?page=item&id=” out, and shortened like “http://qifu.us/s4“, when a user input the shortened url into to address bar, it will be directed to the right page, which is the true url.
I am thinking to save the STATIC part “index.php?page=item&id=” into a string variable, and append the DYNAMIC page id – which is 4 in this example, then use Javascript or PHP to direct to the right page. But I don’t know how the steps, pls help. Thanks.
Actually an htaccess will be very good for this purpose.
For urls like http://qifu.us/s4
do the following: Create a file with name .htaccess
and place at your root directory with the following content.
RewriteEngine On
RewriteRule ^s([^/]*)$ /index.php?page=item&id=$1 [L]