Laboratorium Komputerowe Progmar
Marcin Załęczny

We are using cookies in the page. If you use the page you agree for the cookies.      Close

Htaccess examples

Deny access to files and directories (works recursive in depth):


<Files ~ ".*">
    Order allow,deny
    Deny from all
</Files>
                    

Allow access to files and directories together with mod_rewrite to index.php file:


<Files ~ ".*">
    Order allow,deny
    Allow from all
</Files>

SetEnv APPLICATION_ENV development
DirectoryIndex index.php
RewriteBase /demos/zend-framework/new-project/public/

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
                    

Making redirection (301) to https all addresses that doesn't start with "dev." and making redirection (301) to url that starts with "www." all urls, that starts neither with this prefix nor with prefix "dev.":


RewriteEngine On
RewriteCond %{HTTP_HOST} ^dev\. [NC]
RewriteRule .* - [L]

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

RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.mydomain.pl/$1 [R=301,L]