PDA

View Full Version : Dynamic Subdomains?


Element
10-25-2005, 09:07 PM
I was wondering. I have a script http://urlmask.com which forwards to a long URL with a random token ID... but, I want URLs to be simple to remember, so I was wondering if there is a way to make a dynamic based off the same table struncture, like id=subdomain url=urltogoto and ip=userip. Cause I am planning on having both optional (since with the script deleting every month a user may come into confliction with another user using the subdomain he wanted.

MattyUK
10-27-2005, 06:03 PM
Not sure I grasp your goal fully but:

Have you looked at .HTACCESS mod_rewrite? Assuming a APACHE server of course. I don't know if Windowssupports it fully or not. I doubt it does.

RewriteEngine On
RewriteRule ^(.*).yourdomain.com/url/(*.)$ http://www.yourdomain.com/page.php?id=$1&url=$2 [NC,P,L]

Would allow:
http://123.yourdomain.com/url/www.target.com
to translate to:
http://www.yourdomain.com/page.php?id=123&url=www.target.com
whilst remaining in the browser address bar as:
http://123.yourdomain.com/url/www.target.com

The code above may not be completely correct, I typed I didn't check/test.

More questions on this rather than the php handling of it might be better in the correct forum since it has topic jumped.

MattyUK