Skip to content

Instantly share code, notes, and snippets.

@georgebent
Last active March 6, 2018 07:39
Show Gist options
  • Save georgebent/be04fffe0d492271a1a4f59c6fdf0633 to your computer and use it in GitHub Desktop.
Save georgebent/be04fffe0d492271a1a4f59c6fdf0633 to your computer and use it in GitHub Desktop.
Apache 2 Server Settings
<VirtualHost localhost:80>
ServerName test.dev
ServerAlias www.test.dev
DocumentRoot /home/yura/projects/test.dev
<directory /home/yura/projects/test.dev>
AllowOverride All
Require all granted
</directory>
ErrorLog /home/yura/projects/test.dev/logs/error.log
LogLevel warn
CustomLog /home/yura/projects/test.dev/logs/access.log combined
</VirtualHost>
// add module rewrite
$ sudo a2enmod rewrite
$ service apache2 restart
// add new.site
cd /etc/apache2/sites-available
ls
sudo touch new.site.conf
ls
sudo gedit new.site.conf
sudo a2ensite new.site
sudo mcedit /etc/hosts
sudo service apache2 restart
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
#RewriteRule ^(.*)$ /public/$1 [L]
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 3600 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
ExpiresByType font/woff "access plus 2592000 seconds"
</ifModule>
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf|svg|webp|woff)$">
Header set Cache-Control "max-age=25920000"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "max-age=25920000"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "max-age=25920000"
</filesMatch>
</ifModule>
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE image/svg
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment