Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Help -- Url redirects that members can use?

    I need help on this one.

    I don't know if javascript, or php or .htaccess is the right solution for this one - so please advise. My programming skills are limited to html and cut and paste. With that in mind here is where I need help.

    I have a PHP script that lists properties. It gives each property a listing ID such as 44-10. The Url for the property would be
    http://www.mydomain.com/search_id.php?ID=44-10

    This is obviously too clumsy to use as a referal url for media advertising. Can I use javascript to redirect so that the member can use an url like
    http://www.mydomain.com/44-10 and have it redirect to http://www.mydomain.com/search_id.php?ID=44-10 ?

    If so, what is the best method and what is the code to use? I've spent hours looking on the Internet and have not found a solution.

    Thanks.

    Guy
    Last edited by 4mguy; 12-10-2007 at 06:57 AM. Reason: Checking my notification preferences.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Try this:-

    <form name = "myform">
    <input type = "text" name = "url" size = "40" onchange = "fixUrl(this)">
    </form>

    <script type = "text/javascript">
    function fixUrl(which) {
    var newUrl = which.value.replace(/(\d+)/, "search_id.php?ID=$1");
    //alert (newUrl); // delete after testing
    window.location = newUrl;
    }

    </script>
    Last edited by Philip M; 12-10-2007 at 08:32 AM. Reason: Improvement


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •