View Full Version : [ubuntu] .htaccess stopped working for 301 apache2

April 29th, 2010, 12:53 PM
Greetings all. I am not sure what happened, but my .htaccess file is no longer working for my 301 redirects. I did have a hard time getting it working a few weeks back (when I first set it up), unfortunately I did not document it well.

Main question is for multiple sites getting redirected, do I want the additional sites listed as aliases?

My original setup virtual host config listed seven additional hostnames as aliases. I later had difficulty with google listing these secondary domains within search result and hurting my page rank.

So I setup 301 redirects, and from memory, I had to leave the alias names for the .htacces 301 redirect to work. Now it won't work either way.

Can anyone tell me if the aliases need to be in place?
Do I need to setup individual vhost files and add an .htacces 301 for each? What is the preferred way to do this?

I tried reloading apache2 but it did not help.

Permissions for .htacces:

-rwxr-xr-x 1 eric www-data 866 2010-04-14 12:06 .htaccess

Attaced is my .htaccess. It resides in the site root directory. Also attached is the virtual host config file.


NameVirtualHost *
NameVirtualHost *:443
AddHandler cgi-script .pl
RewriteEngine On

I'm still not sure after hours of reading the various how-to's, what should the file permissions be for the .htaccess.

I have not performed any updates during the period it was working till now.

Any and all help is greatly appreciated.

April 30th, 2010, 12:21 PM
Where's all the love?

I am starting to get a complex.

It appears to me that a large percentage of my threads go unanswered. I must have offended the community in some way,

I am shocked none of the 65 viewers had nothing to add.

Perhaps they were mostly bots?

I gather I'm going to have to create individual vhost files to get it to work. I just wish I could find a cleaner way.

It seems after an apache restart the redirect will work once, but that's it. I have no clue why it worked for a week or so, but not now.

Woe is me...LOL

April 30th, 2010, 02:53 PM
None of this is behaving the way I thought it would.

For the rewrite rules, it seems I cant have multiple conditions point to one rule.

It also seems to be required that aliases be present.

I also seemed to need rewrite rules for ^domain.com and ^www.domain.com.

What am I doing wrong?

I seem to have it working, but it does not appear to me that it should be done this way.

New setup,

Created a vhost file with root directory containing nothing but log directory and .htaccess.

The new vhost I chose one server name and added all the other domains as aliases, including with www. prefix.

I wrote in the .htaccess rules and conditions for ^domain.com and ^www.domain.com. all with corisponding rewrite condition. Why can't I write several rules for one condition? I thought I saw someone reference this here.