htaccess

شرح طريقة كتابة ملف 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
OPTIONS -INDEXES

#Allow directory listing
OPTIONS +INDEXES

#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]
</IfModule>

# temporary redirect / to google.com
Redirect 302 / https://google.com

# permanently redirect / to google.com (better for SEO if you need to redirect)
Redirect 301 / https://google.com

# 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