我如何使用mod_rewrite 301重定向example.com到www.example.com?如何使用、重定向、mod_rewrite、www

由网友(不爱又何必纠缠)分享简介:我需要重定向的任何URL没有WWW。与URL的WWW。为更好的搜索引擎优化。我看,这是有可能的mod_rewrite及.htaccess文件,但我不知道正确的code使用。任何人都可以帮忙吗?I need to redirect any URLs without "www." to URLs with "www."...

我需要重定向的任何URL没有WWW。与URL的WWW。为更好的搜索引擎优化。我看,这是有可能的mod_rewrite及.htaccess文件,但我不知道正确的code使用。任何人都可以帮忙吗?

I need to redirect any URLs without "www." to URLs with "www." for better search engine optimization. I read that this is possible with mod_rewrite and .htaccess files, but I do not know the right code to use. Can anyone help?

推荐答案

在你的根文件夹中创建一个名为.htaccess文件(一个在那里,说,的index.html或index.php文件所在)。把下面进去:

Create a file called .htaccess in your root folder (the one where, say, index.html or index.php resides). Put the following into it:

RewriteEngine   on
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
阅读全文

相关推荐

最新文章