Last active
June 7, 2022 09:01
-
-
Save vaibhav9392/027b7403d84f0bc99abf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Create a .htaccess file in your application root directory. | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond $1 !^(index\.php|public|\.txt) | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.*)$ index.php?$1 | |
</IfModule> | |
<IfModule !mod_rewrite.c> | |
# If we don't have mod_rewrite installed, all 404's | |
# can be sent to index.php, and everything works as normal. | |
# Submitted by: ElliotHaughin | |
ErrorDocument 404 /index.php | |
</IfModule> | |
# Disable server signature | |
ServerSignature Off | |
# DEFLATE by type - html, text, css, xml | |
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml | |
# DEFLATE by type - javascript | |
AddOutputFilterByType DEFLATE application/x-javascript application/javascript text/javascript text/x-js text/x-javascript | |
# DEFLATE by extension | |
AddOutputFilter DEFLATE js css htm html xml | |
2. Change configurations. | |
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'].'/'; | |
$config['index_page'] = ''; | |
3. Enable mod_rewrite module on server | |
sudo a2enmod rewrite | |
4. Restart apache | |
sudo service apache2 restart | |
5. To use mod_rewrite from within .htaccess files edit the default VirtualHost. | |
sudo nano /etc/apache2/sites-available/000-default.conf | |
6. Search for “DocumentRoot /var/www/html” and add the following lines directly below: | |
<Directory "/var/www/html"> | |
AllowOverride All | |
</Directory> | |
7. Restart apache | |
sudo service apache2 restart | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment