如何改变的.htaccess重定向所有非www链接到www网页?重定向、链接、网页、htaccess

2023-09-02 11:40:19 作者:路过你心房

我怎样才能重定向所有非www链接到www的链接?我发现在互联网上的解决方案,但他们只重定向域名。 如何让我这个一般: http://example.com/testing 应重定向到 http://www.example.com/testing

How can I redirect all non-www links to www links? I have found solutions on the internet, but they only redirect the domain name. How do I make this general: http://example.com/testing should redirect to http://www.example.com/testing?

推荐答案

尝试这样的事情

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]