I'm simply trying to redirect any example.com to www.example.com. The redirect currently sends example.com to www.example.com//.
The following code is in my virtual host configuration file:
RewriteCond %{HTTP_HOST} ^suksanvillas\.com$ [NC]
RewriteRule 开发者_如何学C^(.*)$ http://www.suksanvillas.com/$1 [R=301,L]
This seems to be what all the tutorials suggest, but I'm unable to understand how I'm picking up the extra "/" on the redirect. Any help on even where I might look is appreciated.
PS: Other subdomains, for examples "guides.examples.com" should not be redirected.
Thanks.
Avoid capturing the leading slash by using "^/" in the beginning of the pattern:
RewriteRule ^/(.*)$ ...
With that small change everything should work great.
精彩评论