Forum Moderators: phranque
.htaccess) files.
Have a look at your error logs to see what your issue may be.
Redirect [httpd.apache.org]
Is your Rewrite Engine on? It's difficult (for me) to give you a definitive answer without knowing how your file is already configured. You should be able to use something similar to the following code.
RewriteEngine on
RewriteRule ^domain.tld$ http://www.domain.tld [R=301,L]
Permament redirects are common and should not cause any problems on your server. The Apache Web Server Forum [webmasterworld.com] has a Library [webmasterworld.com] full of information.
redirect permanent / http://www.domain.tld
What you said puts the server into a spin and eventually brings up a page not found.
Only if the two domains resolve to the same server.
Optionally, if the domains are on the same server and you have access to the conf directly you could set the redirect in a separate <VirtualHost> container. Now you won't have to invoke mod_rewrite on every request to your domain.
"Optionally, if the domains are on the same server and you have access to the conf directly you could set the redirect in a separate <VirtualHost> container. Now you won't have to invoke mod_rewrite on every request to your domain."
I am sorry to be so dumb but what you wrote might as well be in Swahili. I have a virtual account and can find nothing about virtualhost or containers in my cpanel. I am sorry, you seem to think everyone has their own server and knows about matters past html and electricity. I am simple webmaster who wants to get over a problem with Google. All the threads and explanations I get are gobbly gook to me. The original question was about whether it is possible to do what I want in the htaccess file; clearly it is not after all that. Surely someone can relate to me and knows about normal cpanels and whether and where it is possible to do what I want? If not, if it is a matter for the web hosting company, please someone tell me what to write to them?
PS I do not have two domains.
[edited by: Moncao at 7:19 am (utc) on Sep. 3, 2006]
Swahili? Nope, it's Apache. :) To answer your question, yes, you simply type those lines into your .htaccess file. It isn't a script, per se, it's a directive to the Apache server, telling it to redirect all requests made to domain.tld permanently to www.domain.tld (be sure to replace domain.tld with your own domain information).
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^domain\.tld
RewriteRule (.*) http://www.domain.tld/$1 [R=301,L]