شرح طريقة كتابة ملف htaccess ووظائفه

#the main page is 'index.php', if not found use 'index.html' instead, if it also not found, use 'index.htm'
DirectoryIndex index.php index.html index.htm

#disallow/deny directory listing

#Allow directory listing

#do not follow symbolic links / soft-links
OPTIONS -FollowSymLinks

#allow follow symbolic links / soft-links
OPTIONS +FollowSymLinks

# turn off server signature
ServerSignature OFF

#default WordPress .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]

# temporary redirect / to
Redirect 302 /

# permanently redirect / to (better for SEO if you need to redirect)
Redirect 301 /

# redirect https to http
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# redirect 404 NOT FOUND to HOMEPAGE
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]

# customize error pages
ErrorDocument 404 /404.html
ErrorDocument 403 /403.html