Hello All,
Does anyone know of any easy way, either through a script or through htaccess to shorten a url link?
currently the link looks like this:
http://www.mysite.com/listingview.php?listingID=17
I want to shorten it to something like:
http://www.mysite.com/listingID=17
Any suggestions?
NYColt






chandubhai posted this at 13:39 — 6th March 2004.
He has: 10 posts
Joined: Mar 2004
Please be more elaborate....
NYColt posted this at 13:53 — 6th March 2004.
They have: 42 posts
Joined: Dec 2002
Well,
I have a website where customers place ads.
The actual link from within the website would be, as an example:http://www.mysite.com/listingview.php?listingID=17
or
http://www.mysite.com/listingview.php?listingID=18
and so on....
I would like to shorten the link to something like:
http://www.mysite.com/listingID=17
So that if the advertiser has a newspaper ad they can include the simple internet link http://www.mysite.com/listingID=17 in the add rather than
the more difficult:
http://www.mysite.com/listingview.php?listingID=17
Does that make sense?
NYColt
andy206uk posted this at 16:03 — 6th March 2004.
He has: 1,754 posts
Joined: Jul 2002
If you use Unix/Linux hosting you could use mod rewrite to redirect to make the url look something like
http://www.mysite.com/listing/17
You would need to add something like this to either your httpd.conf or a .htaccess file
RewriteRule ^/listing/\([0-9]{1,4})$ /listingview.php?newsID=$1 [L]'I think that should work. Can't promise you though... its not really one of my specialities.
Andyk
Blog of a Web Designer
Give a man a fish and you feed him for a day. Teach him to use the Net and he won't bother you for weeks.
NYColt posted this at 19:28 — 6th March 2004.
They have: 42 posts
Joined: Dec 2002
great I will try that and let you know how it works
NYColt posted this at 19:47 — 6th March 2004.
They have: 42 posts
Joined: Dec 2002
I added the code to a .htaccess file but I get a "page cannot be found" message.
NYColt posted this at 16:40 — 7th March 2004.
They have: 42 posts
Joined: Dec 2002
Hello Andy,
I got this to work great.
RewriteCond %{REQUEST_URI} ^/([0-9]+)$
RewriteRule ^(.*) /listingview.php?listingID=%1 [L,R]
This produces this:
http://www.mysite.com/17 or another variable
Very Simple and clean, just what I needed!
Hope this thread helps someone else down the trail!
Thanks for the look and see and input on this issue.
NYColt
andy206uk posted this at 09:05 — 8th March 2004.
He has: 1,754 posts
Joined: Jul 2002
Congratulations! I hope it helps people as well, cos it took me absolutly ages to get my head round it when I first wanted to use it!
Andyk
Blog of a Web Designer
Give a man a fish and you feed him for a day. Teach him to use the Net and he won't bother you for weeks.