问题
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
回答1:
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]
回答2:
@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
来源:https://stackoverflow.com/questions/3008080/htaccess-rule-redirect-non-www-to-www-litespeed-server