We often encounter this situation. When other websites link to your site, they will use the following link:
www.example.com
example.com/
www.example.com/index .html
example.com/index.php
This results in: the PR value of your site’s main domain name is scattered to several other URLs.
If you use 301 redirection to redirect the other three URLs to
www.example.com
PR will also be concentrated on the main domain name: www.example.com.
Specific method for 301 redirection:
Set the .htaccess file (only applicable to Linux systems and requires virtual host support.)
So that when accessing example.com/, it will automatically go to www .example.com
Write the following code in the .htaccess file.
RewriteEngine on
RewriteCond %{http_host} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301 ]
Note: URL standardized 301 redirect (the above code) needs to be written before other URL-rewrite codes.
The above is the detailed content of How to set up URL standardization for 301 redirection. For more information, please follow other related articles on the PHP Chinese website!