RewriteEngine On # ^ represent beggining and $ represent end and hence ^$ meaning anything. # and hence anything here will be redirected to public folder ( public will prepend ) in url. RewriteRule ^$ public/ [L] # .* just matches all the characters. RewriteRule (.*) public/$1 [L] ## EXPIRES CACHING ## ExpiresActive On ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType text/css "access plus 1 month" ExpiresByType application/pdf "access plus 1 month" ExpiresByType text/x-javascript "access plus 1 month" ExpiresByType application/x-shockwave-flash "access plus 1 month" ExpiresByType image/x-icon "access plus 1 year" ExpiresDefault "access plus 2 days" ## EXPIRES CACHING ## AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript Options +FollowSymlinks Redirect /md /mate/index.php RewriteRule . /index.php [L] RewriteEngine on RewriteBase / IndexIgnore * RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-z0-9A-Z_-]+)$ /assets/php/show.php?slug=$1 # custom error documents ErrorDocument 401 /md/err/401.php ErrorDocument 403 /md/err/403.php ErrorDocument 404 /md/err/404.php ErrorDocument 500 /md/err/500.php RewriteRule ^dv([0-9]+) /diary.php?recid=$1&ACTION=VIEW [NC] # If subdomain www exists, remove it first RewriteCond %{HTTP_HOST} ^www.([^.]+.[^.]+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301] # If requested resource does not exist as a file RewriteCond %{REQUEST_FILENAME} !-f # and does not end with a period followed by a filetype RewriteCond %{REQUEST_URI} !..+$ # and does not end with a slash RewriteCond %{REQUEST_URI} !/$ # then add a trailing slash and redirect RewriteRule (.*) $1/ [R=301]