htaccess 规则将非 www 重定向到 www - litespeed 服务器

发布于 2024-09-05 03:57:51 字数 726 浏览 2 评论 0原文

我有一个关于在我的 litespeed 服务器中使用 htaccess 的问题。我尝试使用此规则将 http://domain.com 重定向到 http://www.domain.com

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule .* http://www.domain.com/ [L,R=301]

当我检查 http://domain使用Xenu访问.com,结果如下:

http://domain.com/   200 ok text/html 301 Moved Permanently 
http://domain.com/%s  200 ok text/html 301 Moved Permanently  
http://www.litespeedtech.com/ 200 ok text/html LiteSpeed Web Server 
http://www.domain.com/         200 ok text/html redir 

我想知道是否我的htaccess规则不正确或者这是因为litespeed中的错误?我已经在任何地方搜索了几个小时...谢谢

I have a question about using htaccess in my litespeed server. I tried to redirect http://domain.com to http://www.domain.com using this rule:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule .* http://www.domain.com/ [L,R=301]

When I check http://domain.com using Xenu, the result is as follow:

http://domain.com/   200 ok text/html 301 Moved Permanently 
http://domain.com/%s  200 ok text/html 301 Moved Permanently  
http://www.litespeedtech.com/ 200 ok text/html LiteSpeed Web Server 
http://www.domain.com/         200 ok text/html redir 

I wonder whether I had incorrect htaccess rule or this is because of bug in litespeed? I have searched anywhere for hours...Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坏尐絯 2024-09-12 03:57:51

您可以通过以下重写将非 www 子域重定向到 www 子域:

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

You can redirect non-www subdomains to the www subdomain with this rewrite:

RewriteCond %{HTTP_HOST} !^www.domain\.com$
RewriteRule ^/(.*)$ http://www.domain.com/$1 [R=301,L]
夕嗳→ 2024-09-12 03:57:51

@米帕迪:
我猜这不是 301 重定向(或者是?)。这是我从 Xenu 得到的:

http://domain.com/   200 ok text/html Homepage
http://cdn.domain.com/css/style.css  200 ok text/css
http://www.domain.com/about/         200 ok text/html About
http://www.domain.com/contact/         200 ok text/html Contact

@mipadi:
I guess it is not 301 redirected (or is it?). Here is what I got from Xenu:

http://domain.com/   200 ok text/html Homepage
http://cdn.domain.com/css/style.css  200 ok text/css
http://www.domain.com/about/         200 ok text/html About
http://www.domain.com/contact/         200 ok text/html Contact
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文