301 redirect error in htaccess


New Member
when i create .htaccess file
and i insert this code

RewriteEngine on
RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*)$ [R=301,L]

but it comes error like this

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@mydomaincom and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

anyone can help, why?
Hello superman,

I haven't done a lot with redirects but shouldn't there be a domain name or something and a location to be directed to?

Something like this:
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^/?$ http://www.domain.com [R=301,L]
just in case, I had many times this exact error because .htaccess was saved in a malformed txt file. If you are working in Windows, check if your text editor let you save in Unix format.