View Full Version : .htaccess Redirects

12-29-2008, 11:05 AM
I am posting this because I have had some people asking me about this. .htaccess files are great things to use because it can help you keep from having to change a lot of links in your website if you are one of those people that like to make a lot of new pages.

.htaccess files are primarily for redirects and URL rewrites but not limited to just those two things. Here I will talk about redirects.

First to make a .htaccess file you just need to open a text editor program like Notepad. Then you would type in your redirect command. Lets say you wanted to forward all traffic from your homepage to your osCommerce directory called 'catalog'. You would type this in your Notepad:

Redirect /index.html http://domain.com/catalog

The index page all depends on what you called your homepage. Its pretty straight forward. Lets say you wanted to have all traffic go from your regular http request to your secure site at https. You would type in:

Redirect / https://domain.com/

Lets say you changed pageA.html to pageB.html but don't want to have to go and change a whole bunch of navigation links. You would just write a redirect:

Redirect /pageA.html http://domain.com/pageB.html

If you want to redirect your entire site to another domain:

Redirect / http://newdomain.com/

I know for experienced developers this is stupid, but some clients seem to ask these questions repeatedly.

After you have written your redirect command, save the file as .htaccess and upload it to the directory you want it to redirect from. Sometimes notepad might save it as .htaccess.txt. In that case you can simply upload it to your directory, then use File manager to rename it to just .htaccess.