URL Rewrite

Discussion in 'Programming' started by Peoko, Mar 28, 2010.

  1. #1
    Hi,

    Is there any script out there that changes a href="http://www.google.com" into http://domain.com/visit/Google ?
     
    Peoko, Mar 28, 2010 IP
  2. Bompa

    Bompa Active Member

    Messages:
    461
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    58
    #2
    You can do that with htaccess, unless you have hundreds of different domains as the destinations.

    I think if you could explain just a bit more.

    Bompa
     
    Bompa, Mar 28, 2010 IP
  3. Nyu

    Nyu Peon

    Messages:
    79
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If i understand that right you want to change all a href's to "http://domain.com/visit/_SITENAME_"? Do you create these links by your own e.g. have your own php code to generade your site code? I thought of a combination of htacess and php to do this. But i'll need more information about your existing code ;)
     
    Nyu, Mar 29, 2010 IP
  4. lvtim

    lvtim Well-Known Member

    Messages:
    291
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #4
    I use a URL shortener script to do that. I installed YOURLs since it's compatible with my WordPress blog. I don't install it in a subdirectory; instead, I installed in a subdomain so that it'll look like this: http://sub.domain.com/_SITENAME_. It also automatically configures the .htaccess so that redirects are automatic.

    I like YOURLS because it also has a built-in stats to track number of clicks, locations, etc, but I'm not sure whether you'd care for something this extensive.
     
    lvtim, Mar 29, 2010 IP
  5. Peoko

    Peoko Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I`m not using any CMS, so i need a stand-alone solution.

    I have a lot of referal links and i would like to rewrite this links into something like this: mydomain.com/visit/SITENAME.
     
    Peoko, Mar 29, 2010 IP
  6. nimonogi

    nimonogi Active Member

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    80
    #6
    As i can assume each referal link will have different structure, so i think there is no easy way to do that with a stand-alone solution.

    Examples:

    1. This example is if you are using only one affiliate network. Merchant link ID could be dynamically inserted and visitor redirected to affiliate link.
    Now, in this example, your affiliate link number is 123 (a=123), and merchantID is 456 (m=456).
    .htaccess must be placed in separate directory, say "yourdomain/redirect/" , and all "files" in that directory are redirected.
    
    RewriteEngine on
    RewriteRule ^(.*)$ http://network.com?a=123&m=$1 [L,R=301] 
    
    Code (markup):
    Link placed on site page is looking like "yourdomain.com/redirect/456"

    2. Let's say that link to your redirection script is domain.com/cgi-bin/dir/go.cgi?ID=100 (could be php script, not important)
    How about better looking and shorter domain.com/sites/100 ?
    
    RewriteEngine on
    RewriteRule ^(.*)$ http://www.domain.com/cgi-bin/dir/go.cgi?ID=$1 [L,R=301] 
    
    Code (markup):
    3. Let's say that you want to hide affiliate link or simply make shorter and better looking url.
    
    redirect 301 /somename http://YourAffiliateUrl
    
    Code (markup):
    In above example, /somename could be anything, you don't need to make directory with that name, just keep in mind, if that directory already exist, every page in that dir will be redirected to YourAffiliateUrl.

    Good luck.
     
    nimonogi, Mar 29, 2010 IP
  7. Peoko

    Peoko Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    redirect 301 /somename http:// YourAffiliateUrl

    This is what i was looking for. Thank you. I will add the links manually here.
     
    Peoko, Mar 30, 2010 IP