0

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

Répás
  • 1,812
  • 7
  • 28
  • 54

1 Answers1

3
Rewritecond %{HTTP_HOST} !www.domain.com
RewriteRule ^/(.*)$ http://www.domain.com/$1 [L,R=301]
jasonbar
  • 13,333
  • 4
  • 38
  • 46
  • 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` – Répás Aug 13 '10 at 09:20
  • @marharépa, if you use this condition and rule before your index rewrite, it should do exactly that. – jasonbar Aug 13 '10 at 15:07