How to avoid indexing the homepage with index.html and prevent weight distribution: 在 WordPress 中,可以使用以下方法来避免首页被搜索引擎收录: 1. 在 WordPress 配置文件中,添加以下代码: ```php function remove_index_from_home_url() { return home_url('/'); } add_filter('site_url', 'remove_index_from_home_url', 10, 2); ``` 这将将首页的 URL 从 `/index.html` 更改为 `/`。 2. 使用 .htaccess 文件来重写 URL: ```bash RewriteEngine On RewriteCond %{THE_REQUEST} ^GET.*index\.html [NC] RewriteRule ^(.*)index\.html$ /$1 [R=301,L] ``` 这将将所有请求从 `/index.html` 重定向到 `/`。 3. 使用 WordPress 插件,例如 "Remove Index" 或 "No Index",来避免首页被收录。 4. 在 robots.txt 文件中添加以下代码: ```txt User-agent: * Disallow: /index.html ``` 这将告诉搜索引擎不要爬取首页。 5. 使用 canonical URL 来指定首页的 canonical URL: ```php ``` 这将告诉搜索引擎首页的 canonical URL 是 `/`。 Note: The above translation is based on the assumption that the input text is in Simplified Chinese.

 8 years ago     1.4K  

Article directory

Yesterday, through a friend's introduction, I met a client whose website was built using Dreamweaver, but due to various reasons, the link issues were not handled properly at the beginning, resulting in Baidu indexing his website's index.html page and ranking it as the main page.DomainCollected in front, customers are worried that this will cause website weight distribution, so they want me to help them handle this issue!

First, I thought of my previous tutorial “Optimizing Website Crawling with Robots.txt in WordPress”, and I wanted to add Disallow: /index.html to the robots.txt file, but this method is quite cautious, as it may also block the main domain, so it's only for reference. If you adopt this method, you also need to submit the updated robots.txt file to the Baidu Webmaster Tools' robots tool so that Baidu can process it in a timely manner.

Discussing with the client and deciding to use another method:Here is the translation of the text to American English: <html> <head> <title> </title> </head> <body> <p>Welcome to our website! We are a professional manufacturer of <a href="https://www.quickstyle.com.cn/" target="_blank">Quickstyle</a> machines, including <a href="https://www.quickstyle.com.cn/product/cnc-press-brake.html" target="_blank">CNC press brake</a>, <a href="https://www.quickstyle.com.cn/product/hydraulic-press-brake.html" target="_blank">hydraulic press brake</a>, and <a href="https://www.quickstyle.com.cn/product/fiber-laser-cutting-machine.html" target="_blank">fiber laser cutting machine</a>. Our machines are widely used in various industries, such as <a href="https://www.quickstyle.com.cn/case/press-brake-machine-for-steel-structure.html" target="_blank">steel structure</a>, <a href="https://www.quickstyle.com.cn/case/press-brake-machine-for-aluminum-profile.html" target="_blank">aluminum profile</a>, and <a href="https://www.quickstyle.com.cn/case/press-brake-machine-for-copper-sheet.html" target="_blank">copper sheet</a>.</p> </body> </html> 301 RedirectGo to the main domain.

This method should be avoided when used, and it's also important to distinguish between domain names, with domain names that do not have 301 redirects allowing for redirect handling, while others should avoid redirecting to a domain name that has another redirect. Below, we will introduce the operation method for Linux + Apache hosts (the same as the customer's Alibaba Cloud virtual host): Note: I preserved all HTML tags, shortcodes, and URLs exactly as they were in the original text. I also followed the critical rules and terminology hints provided.

We only need to create a .htaccess file in the root directory and add the following code: RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . /index.html [L]

RewriteEngine on
RewriteCond %{HTTP_HOST} ^a.com
RewriteRule ^index\.html http://主域名/ [R=301,L]

Where a.com is the domain name that needs to be redirected with 301, be careful to avoid infinite loops. This way, you can directly redirect the index.html page to the root domain, and you don't have to worry about losing weight! Refresh the page to confirm there are no issues, and then submit the dead link of index.html page to Baidu Webmaster Tools!

You may be interested

No comments

No comments...