Buscar este blog

sábado, 20 de agosto de 2016

Apache HTTP Server - My mini cheat sheet

Not big deal. Just in case I need it someday.

Redirect from HTTP to HTTPS

<VirtualHost *:80>
 Servername cool.sisifo.es

 RewriteEngine on
 RewriteCond %{SERVER_PORT} !^443$
 RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]

 (...)

</VirtualHost>


<VirtualHost *:443>
 Servername cool.sisifo.es

 (...)

</VirtualHost>

Remove "WWW" from domain

<VirtualHost *:443>
 Servername cool.sisifo.es

 RewriteEngine on
 RewriteCond %{HTTP_HOST} ^www\.
 RewriteRule ^(.*)$ https://cool.sisifo.es/$1 [R=301,L]
   
 (...)

</VirtualHost>

Restrict access in certain application paths

Remember, the last one match location has precedence over the others.
<VirtualHost *:443>
 Servername cool.sisifo.es

 <Location />
    Order Deny,Allow
           Allow from all
 </Location>


 <location /myApp/secure/path>
           Order Allow,Deny
           Allow from 127.0.0.1
 </location>

 <location /myApp/othersecure/path>
           Order Allow,Deny
           Allow from 127.0.0.1
 </location>

 (...)
</VirtualHost>

No hay comentarios:

Publicar un comentario