Google News
logo
Slim Framework - Interview Questions
How to Apache configuration in Slim Framework?
Ensure that the Apache mod_rewrite module is installed and enabled. In order to enable mod_rewrite you can type the following command in the terminal :
sudo a2enmod rewrite
sudo a2enmod actions
Ensure your .htaccess and index.php files are in the same public-accessible directory. The .htaccess file should contain this code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
To ensure that the public/ directory does not appear in the URL, you should add a second .htaccess file above the public/ directory with the following internal redirect rule:
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

 

These .htaccess files require URL rewriting.

Make sure to enable Apache’s mod_rewrite module and your virtual host is configured with the AllowOverride option so that the .htaccess rewrite rules can be used: To do this, the file /etc/apache2/apache2.conf must be opened in an editor with root privileges.
 
Change the <Directory ...> directive from AllowOveride None to AllowOveride All.
 
Example : 
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
Finally, the configuration of Apache must be reloaded. To restart Apache web server, enter :
sudo service apache2 restart
This command works on most Debian/Ubuntu variants. For all other Linux distributions, please consult the documentation of your specific Linux distribution to find out how to restart Apache.
Advertisement