PhxSteve
PhxSteve

Reputation: 103

.htaccess file not parsing after upgrade to ubuntu 16.04

I upgraded a digital ocean box from 14.04 to 16.04 and ran in to some issues. The .htaccess file is not being parsed. I can throw garbage at the top of the file which normally breaks a server and it does not matter, leading me to believe it is not being parsed. My ultimate goal is to parse html files as php.

Virtual host settings were not changed after upgrade and worked before.

You can see an instance of the test droplet here: http://162.243.70.81/

I spent about 3 hours digging through other solutions including:

Checking conf file:

//Part of conf file
<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

Checking if rewrite module is enabled

Module rewrite already enabled
service apache2 restart

Review .htaccess file (this is the first few lines and the random chars should result in a 500 if working)

kldlkldfg
AddType application/x-httpd-php .html .inc

editing mime types and looking if some php extensions are not commented out.

When I did the upgrade I did keep old conf files when it said the previous were modified and offered to overwrite or keep. I kept the defaults. Keep in mind everything worked before the upgrade and can be seen at www.pylamdyes.com When I upgraded to php7 I had to disable php5.

That is all of the relevant info I can think to give, happy to try anything or post specific info as requested. Thanks for looking at this.

Upvotes: 0

Views: 330

Answers (1)

Daniel Ferradal
Daniel Ferradal

Reputation: 2900

Define your virtualhost correctly by removing the <Directory /> entry and use this instead:

<Directory /var/www/www.pylamdyes.com>
Require all granted
Options FollowSymLinks
AllowOverride all
</Directory>

About Directory / it should be in server config (outside virtualhosts) like:

<Directory />
Require all denied
AllowOverride none
</Directory>

Also note: if you have access to the server configuration, there is no reason to use .htaccess files. .htaccess files are meant for people without admin rights to configure the web server.

If you need access for another directory, such as the target for that Alias, then define it in the same fashion as the documentroot Directory entry I defined. Policy is and should always be, deny all to /, and give access to the specific directories from where you serve files.

Upvotes: 1

Related Questions