.htaccess file not working in VPS

Discussion in 'Site & Server Administration' started by theonkar10, Sep 16, 2014.

  1. #1
    I am looking to redirect my site abc[dot]com to www[dot]abc[dot]com forcefully using .htaccess file.
    I am using following permissions in my file

    RewriteCond %{HTTP_HOST} ^example.com$
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]

    In my httpd.conf I have made the following change

    IndexIgnore .htaccess
    <FilesMatch "^.ht">
    Order allow,deny
    AllowOverride all //added this line
    Deny from all
    </FilesMatch>

    and rebooted it. Still the same.

    VPS runs cent os 6 64 bit.

    The site was earlier hosted on shared hosting, where .htaccess worked perfectly.
     
    theonkar10, Sep 16, 2014 IP
  2. Krellen

    Krellen Greenhorn

    Messages:
    38
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #2
    I believe you will want to put your AllowOverride in the <Directory> portion of your virtualhost configuration.

    For example:
    <Directory /var/www/>
        AllowOverride All
        allow from all
    </Directory>
    Code (markup):
    Change the directory above to match where your web files are.
     
    Krellen, Sep 17, 2014 IP
  3. Krellen

    Krellen Greenhorn

    Messages:
    38
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #3
    This would most likely not be in httpd.conf. You'd want this in where your actual <VirtualHost> definition is for your domain.
     
    Krellen, Sep 17, 2014 IP