Redirecting browsers to a different web page using .htaccess
Posted by Dr. Zia-al-HassanJun 13
To summarize, add this to your .htaccess file:
Redirect 301 file.html http://www.mydomain.com/newfile.html
Sometimes you want to re-organize your web site. In my case I decided to move articles to a new ‘articles’ folder. So what happens to all the links pointing to the old location? I needed to redirect them. The procedure I will discuss here only works for Apache web servers. You are probably using order medicine online Apache but if not you are probably using a Microsoft web server (IIS). If so, do a web search on keywords like “iss redirect”.
Originally I had an HTML file as so:
http://mydomain.com/my-article.html
I decided I wanted all my articles in an ‘articles’ folder, plus this article I wanted to rename. So in the end, this article was replaced with: http://mydomain.com/articles/my-articles-instead-of-tables.html
The next step was to change all the links on my site to the replacement article.
But what about links from other sites?
Other sites may link to that web page including search engines and search engine robots and spiders. The next thing to do is to use a special file to tell other sites that the article has moved. This file is called .htaccess. This file does much more than just redirects so you may already have this file on your server. You may have one in every directory of your server. It is best to check so you don’t overwrite anything in it cialis rebate that may be important. I’ll write through the step-by-step procedure I used for my file to show you what to do.
- Log onto FTP site and go to the directory containing the original file (my-article.html)
- Look at the directory file and check if .htaccess exists, if it does, download it
- If the directory doesn’t already have an .htaccess file go to step 5
- Open the .htaccess file and move to the bottom of the file so that you don’t change anything in it
- Add the follow line to .htaccess:
Redirect 301 /my-article.html http://mydomain.com/articles/my-articles-instead-of-tables.html - Save the .htaccess file and upload it to the directory that contains the original 36 hour cialis file (my-article.html)
- Optionally, the original file can be deleted
- Test on live web site
301 tells browsers, robots and spiders that the page has moved permanently. If for some reason you are moving the page temporarily you can use 302.
/my-article.html the path to the original file is relative to the directory holding the .htaccess file. Since we are editing the .htaccess file in the same directory as the original file, the source path looks like this.
http://mydomain.com/articles/my-articles-instead-of-tables.html is the new file location. It should be the full absolute path beginning with http. If not, it must begin with a slash and you have to trust the server to add the rest of the path correctly. You are better off just putting in the full URL yourself
Related Posts
- Do Loops in VB .NET
- For Loops in VB .NET
- An Introduction to Loops
- Section Three Exercises
- Conditional Operators
Popularity: 100%
Leave a Reply