How to turn the home page and avoid loops

Source: Internet
Author: User
Keywords Avoid at the same time multiple sites

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Many sites use similar forms to http://www.yourdomain.com/index.html/links to their home pages. The problem is that most of the external links to the home page use http://www.yourdomain.com/, thus dispersing the link weights that point to the site. Notice that the webmaster wants to solve their internal links, from http://www.yourdomain.com/index.html do 301 to http://www.yourdomain.com/. But dealing with bad words can lead to cyclic turning problems.

When someone enters http://www.yourdomain.com/to your website, the Internet DNS system helps the browser find the server where the Web site resides, and then how does the Web server decide what to display to the browser? It calls a file on the Web server's hard disk.

When no file is specified (that is, a domain name is specified, as in the example above), the server calls in a file called the default file. The file name is often index.html/index.htm/index.shtml/index.php or default.asp.

The file name can actually be arbitrary, but most Web servers are set by default to some kind of filename. Many CMS back to show the home page of two forms: http://www.yourdomain.com/and http://www.yourdomain.com/index.php, this will bring problems.

All pages of the site may be linked to http://www.yourdomain.com/index.php, but because of the habit, the third party to your home page links most point to http://www.yourdomain.com/. If the search engine sees the two versions of the first page and considers them to be separate files, the problem of replication content will arise. Google is smart enough to solve this problem, but it's best not to rely on them.

You may decide that the workaround is to use 301 steering from http://www.yourdomain.com/index.php to http://www.yourdomain.com/. Sounds good, unfortunately there's a big problem. When the server sees the http://www.yourdomain.com/index.php request, and then sees that it should turn 301 to http://www.yourdomain.com/, it does so. But when it comes to http://www.yourdomain.com/, the default file (index.php) is transferred to http://www.yourdomain.com/index.php, and then the server sees you are going to the HTTP ://www.yourdomain.com/, this produces an infinite loop.

Default File Steering method

The following method refers to the previous index.php example. You need to put the appropriate default file name for your own server.

1. Copy index.php content to another file. In this example I use sitehome.php.

2. Create an Apache directoryindex directive to the file root directory, set to sitehome.php. Do not set this instruction at the entire server level, otherwise other folders that require index.php as the directory default file may cause problems.

3. In the file root directory in the. htaccess file, put: DirectoryIndex sitehome.php. Or if you don't use a separate file for each directory, put the following code in your httpd.com file:

<Directory/your/document/root/examplesite.com/>
DirectoryIndex sitehome.php
</Directory>

4. Delete the original index.php file content, insert the following line of code:

? Header ("location:http://www.example.com"); >

This setting makes index.php not the directory first file (that is, the default filename). Force read sitehome.php When someone enters a canonical URL (http://www.yourdomain.com/). Requests for index.php from the old link are now turned 301, while avoiding infinite loops.

If you are using CMS, after setting these up, you also need to make sure that all content links point to the canonical URL (http://www.yourdomain.com/). If, for some reason, the CMS starts pointing to http://www.yourdomain.com/sitehome.php, the loop problem can happen again, forcing you to do the whole process again.

Article by Zhanjiang seohttp://www.wwoyy.com First, reprint please keep!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.