One of the most powerful, yet simple manipulations that can be done with your htaccess file is a basic redirect function.
One of the most powerful, yet simple manipulations that can be done with your htaccess file is a basic redirect function. A .htaccess file resides in the web-root directory of most Linux servers that have Apache installed (which is a majority of the servers online). This .htaccess file is a text file which contains user-defined server configuration settings, which include URL manipulations.
The simplest and most common configuration setting is the redirect. Using this function, you can create pseudo directories and files on your local host that will redirect to other URLs. This can be used to hide (or cloak) affiliate links and manage the file linking structure of your website more efficiently. The syntax is simple:
redirect {local/pseudo location} {destination URL}
Example:
redirect /facebook http://www.facebook.com/pa…
If this htaccess file resides on my blog at http://www.matthewbredel.com and I typed in:
http://www.matthewbredel.com/facebook
My host will redirect the user to:
http://www.facebook.com/pages/Ryan-Moran-and-Matthew-Bredel/…
Try it!
Go to: http://www.matthewbredel.com/facebook
I think you would agree that the local URL is much cleaner and easier to remember than the destination URL.
|
Don't Buy Another Money Making Product Until You Watch These FREE Videos! |
My name is Matthew Bredel and as of March, 2007, I am a full-time, work-at-home internet marketer.
For close to 10 years, I worked for a defense company which was an OK job, but I was so uninspired in life and frankly, I needed some more money. That is when I first discovered internet marketing! Now I admit that I didn't start making thousands in my first couple of months (in fact, I lost my shirt!), but I finally saw the "internet light"...

I just had a “duh!” moment. Been trying to figure out a way to do some redirecting, and I hadn’t even though to do an .htcaccess file. Duh… I suppose that’s why you’re the mastermind.
April 7th, 2008 at 9:37 pm
I spent awhile trying to find a solution to this problem (including cheesy cloaking programs, etc.), but they did not work well and these redirects are SO easy. It was a true lightbulb moment when I stumbled about these htaccess files.
April 8th, 2008 at 6:31 am
nice little intro to .htaccess files
April 9th, 2008 at 7:31 am
[...] Htaccess and Redirects for Dummies - A good intro… [...]
April 12th, 2008 at 5:42 am
Matt,
Oh my gosh this looks very easy.I wish I’d seen this post last year when you wrote it!
I say ‘oh my gosh’ because I broke 12 of my websites when I tried to do something like this a few months ago. The nice people at hostgator fixed it for me which was nice of them but didn’t teach me what I did wrong.
So…next week I’m going to see if I can do another one myself. Let’s hope I don’t break anything. LOL.
February 10th, 2009 at 7:58 pm
Hey Dana,
You know you’ll always have me as tech support! But remember that fiddling around with htaccess files can be scary, as you have learned.
Still, it is perhaps one of the most overlooked, under-used, super powerful (and most cryptic!) components of managing a website’s linking structure!
cheers…matt
February 11th, 2009 at 8:24 pm
[...] most of my redirects, I edit my htaccess file: Using Your HTAccess File to Redirect Users. I actually wrote a post on this and did a video, too (see previous link). This may be a little [...]
April 26th, 2010 at 12:45 pm
I have been trying to Gain access to this site for a while. I was using IE7 then when I tried Firefox, it worked just great? Just wanted to bring this to your attention. London,UK
July 10th, 2010 at 1:26 am
Thanks, thats some great information there. Let me know when you update the blog as I would love to keep up to date with your articles.
July 17th, 2010 at 4:16 am
I use Netobjects fusion to create and update my site. I can not figure out a way to use this .htaccess redirect in it. If it can’t be done, how do I get around it?
August 6th, 2010 at 10:00 am
Almost everyone that earnsan income on the internet (even the millionaires) do so through affiliate marketing. Being successful in affiliate marketing involves applying the formula that makes other affiliate marketers successful. For example, autoblogging. Autoblogging is one of the least well-known forms of making money for quite some time… basically because it’s quite difficult to make a good auto-blog. Yet, when done right, it can provide you with a lifetime of passive income with the only real work required being the setting up process. Video Marketing, and several other marketing strategies are all designed to drive traffic to your site, can be incorporated gradually in order to raise the position your site appears in the search engine results page when any one searches for a term related to your site. And yet, even this can be totally automated.
August 17th, 2010 at 6:48 am
Cool thing about .htaccess is if you break your site, just delete the file, revert to your previous version and try again.
November 26th, 2010 at 11:53 pm
I have read a few of the posts on your site now, and I truly like your style of blogging. I added it to my favorites internet site list and will be checking back soon. Please visit my web site too and let me know your thought.
April 18th, 2011 at 8:35 am
This was THE BEST cite explaining the URL re-writes. Others make it soooo complicated. Thank you , I could not believe how quickly I got this done. I am very busy and don’t leave feedbacks almost at all but this time the comment is so deserved that I could not miss it.
November 20th, 2011 at 11:53 am
hello,
iam trying to redirect error page to a custom error page by using the follow .htaccess code { ErrorDocument 404/error.html } but
when i open my document in browser it is giving me error saying
{ Internal Server Error } can you please help me to solve the problem
December 28th, 2011 at 3:58 pm