.htaccess file

I set up a virtualhost using virtualmin but I don’t find the .htaccess file anywhere, do I have to make the file ?

You don’t need an .htaccess file to set up a virtualhost unless you have a specific purpose in mind?

i need to redirect the non www version of my website to the www version so i need the file, do i have to create the file ?

Yeah, the easiest way to redirect from domain.tld to www.domain.tld would probably be to create a .htaccess file.

There’s an example of something similar to what you’d need here:

http://www.scriptalicious.com/blog/2009/04/redirecting-www-to-non-www-using-htaccess/

i gotta create the .htaccess file or it is there in some directory ?

You’ll want to create a .htaccess file in your DocumentRoot, and using the contents at the link I mentioned above as an example of what to put in it.

-Eric

If you run a CMS on your site, you can probably use a “plugin” or “extension”. That is probably easier for you :slight_smile:

I created a .htaccess file and made sure that I have

LoadModule rewrite_module modules/mod_rewrite.so

in my httpd.conf, I restarted my server and it is still not redirecting.

What did you put into .htaccess file?

RewriteEngine On RewriteCond % ^megahotserved.com [NC] RewriteRule ^(.*)$ http://www.megahotserved.com/$1 [L,R=301]

and when I tried

<VirtualHost *:80>
ServerName megahotserved.com
Redirect permanent / http://www.megahotserved.com/

in the httpd.conf file, when I restarted apache firefox came up with an error

"The page isn’t redirecting properly.

Firefox has detected that the server is redirecting the request for this address in a way that will never complete."

I found the problem it is
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.megahotserved.com
RewriteRule ^(.) https://megahotserved.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.megahotserved.com
RewriteRule ^(.
) https://megahotserved.com:10000/

What are the above statements used for ? Are they necessary ?

Hmm, those two lines shouldn’t be causing any problems – they simply make it so that anyone browsing to webmail.yourdomain.com or admin.yourdomain.com get redirected to Usermin or Virtualmin.

However, if you don’t need those redirects, you are welcome to remove them :slight_smile:

-Eric

when i go to admin.mydomain.com i get an error saying
" server not found ", how are they working then ?

Those lines shouldn’t be breaking anything in your setup. However, it they may only work if there’s a DNS entry for “admin.mydomain.com”.

If you’re hosting your DNS on a server other than your Virtualmin server, you may need to manually create that DNS entry at your DNS provider.

-Eric