.htaccess file

14 posts / 0 new
Last post
#1 Tue, 03/01/2011 - 08:17
vald

.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 ?

Tue, 03/01/2011 - 08:52
helpmin

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

Tue, 03/01/2011 - 11:19 (Reply to #2)
vald

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 ?

Tue, 03/01/2011 - 12:20
andreychek

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-us...

Tue, 03/01/2011 - 12:32 (Reply to #4)
vald

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

Tue, 03/01/2011 - 12:39
andreychek

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

Tue, 03/01/2011 - 19:47 (Reply to #6)
vald

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.

Tue, 03/01/2011 - 20:29 (Reply to #7)
helpmin

What did you put into .htaccess file?

Tue, 03/01/2011 - 22:33 (Reply to #8)
vald
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/
</VirtualHost>

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."

Tue, 03/01/2011 - 18:47
helpmin

If you run a CMS on your site, you can probably use a "plugin" or "extension". That is probably easier for you :-)

Wed, 03/02/2011 - 06:32
vald

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 ?

Wed, 03/02/2011 - 11:38
andreychek

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 :-)

-Eric

Wed, 03/02/2011 - 13:33 (Reply to #12)
vald

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

Wed, 03/02/2011 - 13:39
andreychek

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

Topic locked