views:

18

answers:

1

This is my .htaccess, and I'd like to rewrite my domain.com to www.domain.com. How can i do this?

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|css|js|pl|xml|txt)$
RewriteCond %{REQUEST_URI} !example/
RewriteRule ^(.*)$ index.php?q=$1 [QSA]

Thanks

+2  A: 
Rewritecond %{HTTP_HOST} !www.domain.com
RewriteRule ^/(.*)$ http://www.domain.com/$1 [L,R=301]
jasonbar
Great solution, unfortunately I already known this, but it's not working with my rewrite.I need all the links to go to the index file. Like: `http://www.domain.com/oinon` and `http://www.domain.com/whatdoyoulike/elephants` all opens the `root/index.php`
neduddki
@marharépa, if you use this condition and rule before your index rewrite, it should do exactly that.
jasonbar