Hi, anyone, i have a question :
i want to redirect the example.com to www.example.com ,but it donest work.... i search the problem with several days, i do make changed to the .htaccess:
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

i dont know how it works, i made clean urls in my web.config. and my website in my service windows 2003 with iis 7.

someone can help me?

Comments

blackarma’s picture

Hey linezing.

I don't know nothing about iis servers, but for apache with enabled .htaccess read futher.

Basically your code do not turn on Rewrite engine so code most probably don't work.

Try this instead in your .htaccess file

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

Of course put your domain instead example :)

linezing’s picture

Hi, thanks for your reply.

i have found the problem it is in IIS7.

because i delete the .htaccess file in my web root, the website works fine, so i search in google, "drupal .htaccess web.config" , i found the point, that is Windows IIS use web.config not .htaccess, so i need to put code on web.config not .htaccess.

http://learn.iis.net/page.aspx/557/translate-htaccess-content-to-iis-web...







i added this code to root-> web.config . it works.

i write this for who used IIS to run drupal. it help.....

thanks, drupal is a great CMS.