In my site’s root directory, i create a file named .htaccess. and put the following code into it.but when i access example.com/test.html.
It not redirect to http://www.example.com/test.html
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC];
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
thank you, what’s the reason of it?
Remove the semicolon at the second line.
Try this