Apache 2.4.6 default.conf format changed. Failed to start .htaccess

Guys. I am using codeigniter. I used .htaccess to remove 'index.php' from my url and added "Allow from all" to my default.conf. "index.php" was successfully deleted and the site started. But since the latest apache update, .htacess stopped working and index.php became necessary in the url. This is my new updated 000-default.conf.

<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 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 # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, eg #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> #vim: syntax=apache ts=4 sw=4 sts=4 sr noet 

I added the following lines to my 000-default.conf, but didn't work:

 AllowOverride all Order allow,deny Allow from all 

My .htaccess is good because it worked fine until the last Apache update.

 Options -Indexes RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|assets|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] RewriteCond %{REQUEST_URI} ^htaccess/ [NC,OR] RewriteCond %{REQUEST_URI} ^system/function/ [NC,OR] #just make sure the last rule does NOT have an OR RewriteCond %{REQUEST_URI} ^system/class/ [NC] RewriteRule . - [R=404,L,NC] 

My apache version is 2.4.6. Now, please tell me what to add to the 000-default.conf file to get .htaccess and remove "index.php" from my site url.

PS: I am using ubuntu 12.04. mod_rewrite is enabled. I included 000-default.conf, that is, it is available in the folder with the sites included.

+7
ubuntu codeigniter .htaccess apache2
source share
3 answers

I'm still new to the server / command line, so I thought that I would add a step-by-step solution for others in a similar place. Hope this helps someone:

  • Log in to your server.

  • Open the 000-default.config file with nano:

     $ sudo nano /etc/apache2/sites-available/000-default.conf 
  • Look at this line in VirtualHost: DocumentRoot /var/www/html and add the following below:

     <Directory /var/www > AllowOverride All </Directory> 
  • Save the changes: Press CTRL + O to write; then press RETURN to save the changes.

  • Exiting Nano: Press CTRL + X

  • Reboot the server:

     $ sudo service apache2 restart 
  • If you need to activate the apache mod_rewrite module, run the following command:

     $ sudo a2enmod rewrite 

    And if the module is already activated, you will receive a message saying that everything is fine.

+8
source share

It's a little outdated, but since I see it now and I did it, maybe it will make it clear someone will stumble on it.

You open the file 000-default.conf and find where it says "/ var / www", and then put this in:

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

Then just save and restart apache. You also need to enable mod_rewrite for Apache. It is easy to find by googling.

+7
source share

 ServerName localhost ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /var/www > AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined 

;)

+1
source share

All Articles