Question

On ubuntu 13.10 I am using apache 2.4.x . I was having problem with mod_rewrite. I enabled that module and and restarted the server but .htaccess file wasn't still working so I after some search, I read an answer from stackoverflow pointing towards: http://smarttips.in/htaccess-redirect-not-working-apache/

I was missing point 2 in the above link. So I put that code in my 000-default.conf file.

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

As I am using apache2.4+ so as told here: http://httpd.apache.org/docs/current/upgrading.html

Order allow, deny
Allow from all

to

Require all granted

Here is code in my 000-default.conf file:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www
     <Directory />
      Options FollowSymLinks
         AllowOverride All
     </Directory>
     <Directory /var/www/>
      Options Indexes FollowSymLinks MultiViews
       AllowOverride All
       Require all granted
    </Directory>
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
    </VirtualHost>

But after entering that code from that link, now server is giving 403 forbidden, saying:

You don't have permission to access /mysite/ on this server.
Apache/2.4.6 (Ubuntu) Server at localhost Port 80

So not sure if that mod_rewrite problem is solved or not but also getting now permissions error. Let me know if I need to put .htaccess code here too.

So any idea what am I doing wrong ?

Was it helpful?

Solution

I simply removed:

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

and put this instead:

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

And now that permission error is gone and mod_rewrite is working as expected.

OTHER TIPS

Adding this to <Directory /var/www/html>

Options +SymLinksIfOwnerMatch

helped me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top