4

I already install apache2 then i enable the mod_rewrite module like this:

sudo a2enmod rewrite

after enabling i am confused about these lines, i can't understand what to do with them, as far as i know that what i have to do with these lines is that " find the following section, and change the line that says AllowOverride from None to All. "

<Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
</Directory>

my problem is that I can't find a file with the above lines to edit. I already looked in /etc/apache2/sites-available/. In that directory, I only found two files:

000-default.conf 
default-ssl.conf 

In both files i can't find above lines which i have to edit.

i edit the file /etc/apache2/apache2.conf in this directory but it still didn't worked at all.

i also looked in this /etc/apache/sites-enabled/default.conf directory but i can't find these lines in dafault.conf

<Directory /var/www/html>
    AllowOverride All
</Directory>

i am working in /var/www/html directory then why it's giving me 403 forbidden error.

Still .htaccess is not running. It's giving me 403 forbidden error.

here is the screen shot of folder permission:

enter image description here

here is the screen shot of 403 forbidden error: enter image description here

jazz_razor
  • 73
  • 1
  • 2
  • 7

5 Answers5

6

Edit /etc/apache2/apache2.conf instead of /etc/apache2/sites-available/ and edit as instructed.

Here's mine:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
Parto
  • 15,027
  • 24
  • 86
  • 114
3

Firstly, in Ubuntu 14.04 (and Apache 2.4) the default DocumentRoot was changed from /var/www to /var/www/html. Secondly, the configuration was considerably simplified, so those entries, while usually present by default, no longer appear in the new default site configuration.

Edit /etc/apache/sites-enabled/default.conf, and add these lines:

<Directory /var/www/html>
    AllowOverride All
</Directory>

Your 403 Forbidden error is possibly because you are working in /var/www where you should be working in /var/www/html.

Finally, you shouldn't be enabling All, but pick out the options you need and enable only those.

muru
  • 193,181
  • 53
  • 473
  • 722
  • cant find above line in default.conf – jazz_razor Oct 05 '14 at 02:30
  • @jazz_razor You are supposed to *add* these lines, above the line with ``. – muru Oct 05 '14 at 07:54
  • i added these lines but it still giving me 403 forbidden error – jazz_razor Oct 05 '14 at 07:58
  • i am working in this directory /var/www/html/my_project – jazz_razor Oct 05 '14 at 07:59
  • @jazz_razor I doubt your 403 error has anything to do with htaccess configuration. Have you set permissions correctly? – muru Oct 05 '14 at 08:01
  • yes i set permissions correctly. in this `/var/www/html/` directory i can create folders, files and i can perform delete, edit actions easily through editor.. – jazz_razor Oct 05 '14 at 08:08
  • @jazz_razor yes, but are the permissions proper for Apache? Can the server read those files? – muru Oct 05 '14 at 08:29
  • yes server can read those files. – jazz_razor Oct 05 '14 at 08:32
  • if i change the pattern of url like this: `http://192.168.1.2/test.php` it runs the php code but when i switch url like this: `http://192.168.1.2/seocompany/` it gives me 403 forbidden error – jazz_razor Oct 05 '14 at 08:33
  • @jazz_razor Did you restart apache after you did the modifications to the `000-default.conf` file? You can restart it with `sudo apache2ctl restart`. If you did, are you sure the rewrite rules are correct? – Dan Oct 07 '14 at 16:51
  • yes i restart the apache and my rewirte rules are correct because website is running live. – jazz_razor Oct 10 '14 at 02:14
1

Ubuntu 14.04 (and Apache 2.4) the default DocumentRoot was changed from /var/www to /var/www/html.

sudo nano /etc/apache2/sites-enabled/000-default.conf

add these lines at end

<Directory /var/www/html> AllowOverride All </Directory>

and of course >

sudo service apache2 restart

0

I had the same issue. Changing the privileges of my .htaccess file to 755 seemed to work.

Lee
  • 13
  • 1
  • 4
  • 1
    For security reason, other users may only read your .htaccess, you should use _sudo chmod 644 /var/www/html/.htaccess_ to update permissions. – Ramesh Chand Feb 01 '16 at 08:15
0

Ubuntu 14.04 (and Apache 2.4) the default DocumentRoot was changed from /var/www to /var/www/html.

sudo nano /etc/apache2/sites-enabled/000-default.conf

add these lines at end

<Directory /var/www/html>
    AllowOverride All
 </Directory>

and of course restart apache2 service

sudo service apache2 restart
pl_rock
  • 11,067
  • 7
  • 41
  • 41