Creating 4 Redirect URLs, (using Htaccess) ?

by 11 replies
13


























#programming #creating #htaccess #redirect #urls
  • Code:
    Redirect 302 /Surprise1 http://www.AffiliateProduct1.com
    Redirect 302 /Surprise2 http://www.AffiliateProduct2.com
    Redirect 302 /Surprise3 http://www.AffiliateProduct3.com
    Redirect 302 /Surprise4 http://www.AffiliateProduct4.com
    Substitute your own URLs in the above. Place the .htaccess file in the webroot directory of mydomain.com.
    • [1] reply
  • It's pretty simple..... in "SteveJohnson's" example it will redirect the file "/Surprise1" (ie; mydomain.com/Surprise1") to "AffiliateProduct1.com" & so on..

    The 302 just means it's a temporary redirect & not a permanent one.
    • [1] reply
  • Temporary vs permanent is up to you. Use permanent if you think that the links will never change. I prefer temporary because I might drop the affiliate at a certain moment, and also because a 301 (permanent) redirect passes link juice to the target (unless you use a nofollow link to your /Surprise pages (which is highly recommended).

    For a permanent redirect, use 301 instead of 302 in Steve's script.

    The .htaccess is a simple text file, but you need to leave the name just like that. I.e., .htaccess, NOT .htaccess.txt or .htaccess.htm
  • I use 302 redirects on aff links because I want the visitor's browser checking every time. If you use a 301 (which is totally fine, if you're sure the target destination will never change), the browser knows it has been redirected permanantly and caches the result, never to check again until its cache expires.

    Or at least that's the theory.
    • [1] reply
  • I'm pretty sure they don't have to exist... as the server will just redirect anyone going to that URL to the new URL; don't think it bothers to check if it exists.

    Though if you have 404 redirection code in there too, not sure how friendly it plays with that.... probably best to just create blank files.
  • No need to create files, they do NOT have to exist. Your server looks at the .htaccess file for the folder before it looks for and attempts to load a file.

    The only time a 404 is sent by the server is when it attempts to load a file that isn't there. In your case, it's not even getting to that stage.
    • [1] reply

Next Topics on Trending Feed