WEB WebApp to do redirects??

Discussion in 'OT Technology' started by grooves12, Aug 21, 2007.

  1. grooves12

    grooves12 New Member

    Joined:
    Oct 3, 2003
    Messages:
    5,561
    Likes Received:
    0
    Location:
    Bay Area, CA
    I am looking for a way to set up a small app on a host I own that would receive a URL as an argument and then do an immediate redirect to that URL.

    Does anyone know how I would accomplish this?
     
  2. SkyLeach

    SkyLeach Guest

    why do you need a webapp for this? Just use mod_rewrite and .htaccess on apache.
     
  3. Insert Tokens

    Insert Tokens Making Cancer My Bitch OT Supporter

    Joined:
    Jan 12, 2006
    Messages:
    8,329
    Likes Received:
    75
    Location:
    Tasmania
    Code:
    <? 
    header("Location: http://$link"); 
    ?>
    
    Then pass it using ?link=whatever.com


    Got no FTP access atm to check, but I don't see why the above wouldn't work? Unless the header function doesn't allow variables in it.
     
  4. SkyLeach

    SkyLeach Guest

    RewriteEngine on
    RewriteRule ^.*\?arg=(.*) $1 [R,L]


    done, and 1,000x faster than any webapp.
     
  5. grooves12

    grooves12 New Member

    Joined:
    Oct 3, 2003
    Messages:
    5,561
    Likes Received:
    0
    Location:
    Bay Area, CA
    not sure what is meant... I am a newb to anything web related. Just want a link sent to my host with a different URL as an argument to redirect to a different site.
     
  6. Aslan

    Aslan My avatar is the new hotness... yours... Old and b

    Joined:
    Jun 1, 2001
    Messages:
    4,823
    Likes Received:
    0
    Location:
    NW burbs o' Chicago
    well written. htaccess master
     
  7. Aslan

    Aslan My avatar is the new hotness... yours... Old and b

    Joined:
    Jun 1, 2001
    Messages:
    4,823
    Likes Received:
    0
    Location:
    NW burbs o' Chicago
    yeah you can use the php thing above, should work fine.
    or create a php page - jumplink.php
    that does a timed redirect while displaying text - "please wait you are being redirected"
    then you call the page

    Code:
    http://www.wwkljwlkjw.com/jumplink.php?url=http://www.yahoo.com
     
    Last edited: Aug 21, 2007
  8. SkyLeach

    SkyLeach Guest

    well, I didn't test it or anything :hsugh:

    but, I did implement a mod_rewrite clone in java for content management and rewrite so...
     
  9. massy

    massy New Member

    Joined:
    May 8, 2006
    Messages:
    24
    Likes Received:
    0
    I'm looking for a redirect thingie for a site of mine. If the visitor goes to blabla.com/something, I want that redirected to blabla.com/page.php?var=something.

    I can do it in the control panel but therefore I need to enter every "something" value manually, and I don't like to work.
     
  10. SkyLeach

    SkyLeach Guest

    modified for your needs...
     
  11. massy

    massy New Member

    Joined:
    May 8, 2006
    Messages:
    24
    Likes Received:
    0
    Thanks for the modification but it doesn't work like i want it to.

    Pictures are in the folder auto/picname.jpg ==> redirect to stem1.php?mk=picname.jpg => it shouldn't do this!

    If I try blabla.com/anything ==> no redirect, only a 404
     
  12. SkyLeach

    SkyLeach Guest

  13. grooves12

    grooves12 New Member

    Joined:
    Oct 3, 2003
    Messages:
    5,561
    Likes Received:
    0
    Location:
    Bay Area, CA
    What would the link need to look like when you send the variable with this?
     
  14. SkyLeach

    SkyLeach Guest

  15. SkyLeach

    SkyLeach Guest

    You need to understand a little about regular expressions

    cliffs: the rewrite engine uses regular expressions to match a pattern (in this case any incoming request for anything) that also contains an HTTP GET style query string starting with the variable arg and the value expected is a fully qualified url to a host you want to redirect to.

    There is very good documentation on how to use mod_rewrite here:

    http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

    let's say your .htaccess is in <web_root>blahblah/.htaccess

    if someone goes to http://yoursite.com/blahblah?arg=foo then mod_rewrite would see /blahblah?arg=foo (the http://yoursite.com is the proto and hostname part of the request and is stripped off before mod_rewrite gets it). You can still access those values though:

    Code:
    HTTP headers: 	connection & request: 	
    HTTP_USER_AGENT
    HTTP_REFERER
    HTTP_COOKIE
    HTTP_FORWARDED
    HTTP_HOST
    HTTP_PROXY_CONNECTION
    HTTP_ACCEPT
    	REMOTE_ADDR
    REMOTE_HOST
    REMOTE_PORT
    REMOTE_USER
    REMOTE_IDENT
    REQUEST_METHOD
    SCRIPT_FILENAME
    PATH_INFO
    QUERY_STRING
    AUTH_TYPE
    	
    server internals: 	system stuff: 	specials:
    DOCUMENT_ROOT
    SERVER_ADMIN
    SERVER_NAME
    SERVER_ADDR
    SERVER_PORT
    SERVER_PROTOCOL
    SERVER_SOFTWARE
    	TIME_YEAR
    TIME_MON
    TIME_DAY
    TIME_HOUR
    TIME_MIN
    TIME_SEC
    TIME_WDAY
    TIME
    	API_VERSION
    THE_REQUEST
    REQUEST_URI
    REQUEST_FILENAME
    IS_SUBREQ
    HTTPS
    You really should RTFM here. It's knowledge you will never regret having if you use the internet regularly.

    http://yoursite.com/
     

Share This Page