301 in .htaccess forces a jump to a domain name with www prefix or without www

888u

Last update at :2024-04-29,Edit by888u

I believe many webmaster friends have such problems. That is, domain names with www prefix and top-level domain names without www prefix are included differently. This problem is mainly caused by the different weight determination of top-level domain names and second-level domain names by search engines.

There is no doubt that a unique domain name can bring you more benefits. No matter it is with www or without www. Because, both users and search engines will remember the unique domain name of your website. It will not cause a diversion of weight.

We'll show you how to force users or search engines to redirect to a unique domain name in .htaccess.

#Force redirect to www

RewriteEngine On

RewriteCond %{HTTP_HOST} ^138vps.com [NC]

RewriteRule ^(.*)$ http://www.138vps.com/$1 [L,R=301]



#Force redirect to the top-level domain name without www

RewriteEngine On

RewriteCond %{HTTP_HOST} !^138vps.com$ [NC]

RewriteRule ^(.*)$ http://138vps.com/$1 [L,R=301]

Recommended site search: American virtual space, VIP domain name, personal free space, domain name query official website, high-defense server, proxy Server IP, game server rental, foreign trade hosting, domain name registration network, asp.net space,

301 in .htaccess forces a jump to a domain name with www prefix or without www

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码