Many websites use a link similar to this http://www.yourdomain.com/index.html/ to their home page. The problem is that most of the external links pointing to the homepage of the website use http://www.yourdomain.com/ , thus dispersing the weight of the links pointing to the website. Webmasters who have noticed this and want to resolve their internal links should do a 301 redirect from http://www.yourdomain.com/index.html to http://www.yourdomain.com/ . But if it is not handled well, it will cause circular steering problems.
When someone enters http://www.yourdomain.com/ and comes to your website, the Internet DNS system helps the browser find the server where the website is located. Then how does the website server decide what to display to the browser? It needs to call the server on the hard disk of the website server. a file.
When no file is specified (that is, as in the above example, only the domain name is specified), the server loads a file called the default file. The file name of this file is usually index.html/index.htm/index.shtml/index.php or default.asp.
The filename can actually be anything, but most web servers default to some kind of filename. Many CMS will display two forms of website homepage: http://www.yourdomain.com/ and http://www.yourdomain.com/index.php , which will cause problems.
All pages of the website may be linked to http://www.yourdomain.com/index.php , but due to habit, most of the homepage links given to you by third parties point to http://www.yourdomain.com/ . If search engines see two versions of the home page and think they are separate files, you will have a duplicate content problem. Google has been smart about solving this problem, but it's best not to rely on them.
You may decide that the solution is to use a 301 redirect from http://www.yourdomain.com/index.php to http://www.yourdomain.com/. Sounds great, but unfortunately there's a big problem. When the server sees a request for http://www.yourdomain.com/index.php and sees that it should redirect 301 to http://www.yourdomain.com/ , it does so. But when it calls http://www.yourdomain.com/, to get the default file (index.php) it has to call http://www.yourdomain.com/index.php , and then the server sees you To redirect to http://www.yourdomain.com/ , this creates an infinite loop.
Default file redirection 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 the contents of index.php to another file. In this example I use sitehome.php.
2. Create an Apache DirectoryIndex directive for the file root directory and set it to sitehome.php. Do not set this directive at the entire server level, otherwise problems will occur in other folders that also need index.php as the default file in the directory.
3. Put: DirectoryIndex sitehome.php in the .htaccess file in the root directory of the file. Or if you are not using separate files 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 contents of the original index.php file and insert the following line of code:
<? header("Location:http://www.example.com");?>
This setting makes index.php not the directory homepage file (that is, the default file name). Force sitehome.php to be read when someone enters the canonical URL ( http://www.yourdomain.com/ ). Requests to index.php from the old link are now redirected with a 301, while avoiding an infinite loop.
If you use a CMS, after setting up the above, you also need to ensure 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 looping problem will occur again, forcing you to do the entire process over again.
The article was first published by Zhanjiang SEO http://www.wwoyy.com, please keep it for reprinting!
(Editor: Yang Yang) The personal space of the author Tiandao Ruowen