ErrorDocument 401 /htaccess/401.html#Page not found error
ErrorDocument 404 /htaccess/404.html#Internal Server Error
ErrorDocument 500 /htaccess/500.html
Redirect /old_dir/ http://www.yourdomain.com/new_dir/index.html
AuthName "Member's Area Name"
AuthUserFile C:\xampp\htdocs\wp-content/.htpasswd
AuthType Basic
require valid-user
order allow,denyThe following code will cause a 404 error to appear if anybody attempts to view the file wp-config.php
#deny from 127.0.0.1
deny from 123.45.6.
allow from all
<Files ~ "/wp-config.php">
Order Allow,Deny
Deny from All
</Files>
RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} otherdomain\.com [NC]
RewriteRule .* - [F]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1.*$ http://example.com/folder2/ [R=301,L]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1.*$ http://example.com/ [R=301,L]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder1/(.*)$ http://gs.mt-example.com/folder2/$1 [R=301,L]
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} example.com$ [NC] #URL must start with example.com
RewriteCond %{HTTP_HOST} !folder1 #URL should not contain folder
RewriteRule ^(.*)$ http://example.com/folder1/$1 [R=301,L]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteEngine OnAnother example to force https:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
RewriteEngine OnRewriteCond %{HTTPS} !=onRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|css)$ - [F]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/hotlink.jpg [R,L]
DirectoryIndex index.html
DirectoryIndex index.html index.cgi index.php
AddType text/html htm0 #AddType MIME-Type extension
AddType application/x-shockwave-flash swf
IndexIgnore *or to give a forbidden message,
Options -IndexesTo hide only '.zip' files
IndexIgnore *.zipTo prevent listing multiple file types
IndexIgnore *.zip *.jpg *.gifAlternatively, if your server does not allow directory listings and you would like to enable them
Options +Indexes
SetEnv TZ America/Los_Angeles
RemoveHandler cgi-script .pl .cgi .php .py
AddType text/plain .pl .cgi .php .py
AddType application/octet-stream .zip .mp3 .mp4
#Adding a .php extension to all http requests
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ $1.php [NC,L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
$_GET['path']
to get the requested url.RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L,QSA]
use $_SERVER['REQUEST_URI'] to get the requested url.NC
= No Case (not case sensitive, not really necessary since there are no characters in the pattern)L
= Last (it'll stop rewriting at after this Rewrite so make sure it's the last thing in your list of rewrites)QSA
= Query String Append, just in case you've got something like ?like=penguins
on the end which you want to keep and pass to index.php.RewriteEngine onRewriteRule ^$ /routes.php [L,QSA]
RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^.*$ /routes.php [L,QSA]
RewriteEngine On
# Map https://stading.themovers.my to /public.
RewriteRule ^$ /public/ [L]
# Map https://stading.themovers.my/x to /public/x unless there is a x in the web root.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1
# Add trailing slash to directories within public
# This does not expose the internal URL.
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule ^public/(.*[^/])$ ./$1/ [R=301]
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Others
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
Labels: Web development