2

I cant get my .htaccess file to work correctly.

In my apache2.conf file I have the following.

<Directory /home/felix/mysite>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

But this does not change anything. I still get a 404 error when trying to reach different pages on my website.

EDIT more info:

Ubuntu 16.04

Apache 2.4

Inside my sites sites-available I have my mysite.se.conf file which looks like:

<VirtualHost *:80>    
    ServerAdmin webmaster@localhost
    DocumentRoot /home/felix/mysite
    ServerName mysite.se
    ServerAlias www.mysite.se

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I tried removing this part from apache2.conf:

<Directory /home/felix/mysite>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

And got this message now You don't have permission to access / on this server. Server unable to read htaccess file, denying access to be safe.

I get this message now even when I added that part back.

The site which I am trying to get to work is built with wordpress. Inside the root folder of this site I have an .htaccess file which looks like this:

# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0
# End Error

# BEGIN WordPress
<IfModule mod_rewrite.c>
ReewriteEngine On
eRewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

The thing is that these settings works on another Ubuntu machine. And the server administartor could not find the error in mine. So he said that is probobly a some faults in the apache2 configuration. But I cant locate it, everything seems to be as it should.

I think this could be at fault: https://www.digitalocean.com/community/questions/wordpress-permalinks-not-working-on-ubuntu-14-04

specifically: Also make sure your .htaccess file has the proper permissions for WP to write to it. You'll see an error if it doesn't.

How can I change it to right permission?

SOLUTION:

I am sorry that I cant give a better solution. But all I did was sudo a2enmod rewrite then sudo service apache2 restart. First time I did this I got an error (500 server error or a 403 permission error, cant remember) but tried it again this morning and it worked. So my files still looks as the above.

  • To be able to help, we will need more information. I do not think it is an .htaccess file problem, and for some initial testing I suggest you delete it so as to first get things working without any .htaccess. We also need to see whatever you did for your /etc/apache2/sites-available/? file. – Doug Smythies Mar 7 '17 at 15:08
  • Alright, sorry! Will edit my post! – Felix Rosén Mar 7 '17 at 15:09
  • @DougSmythies Please see edit! – Felix Rosén Mar 7 '17 at 15:18
2

Try to edit mysite.se.conf:

<VirtualHost *:80>    
    ServerAdmin webmaster@localhost
    DocumentRoot /home/felix/job/fello
    ServerName test.fello.se
    ServerAlias www.test.fello.se
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory "/home/felix/job/fello">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

And check path to you site /home/felix/mysite or /home/felix/job/fello ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.