RewriteEngine On
RewriteBase /

# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [L,R=301]

# Redirect /exam-help to /take-my-online-exam
RewriteRule ^do-my-online-exam/?$ / [R=301,L]

# Remove Escape Fragment from the link
RewriteEngine On
RewriteCond %{QUERY_STRING} _escaped_fragment_
RewriteRule ^(.*)$ /$1? [R=301,L]

# index.php to (/)
RewriteCond %{THE_REQUEST} \s/index\.php [NC]
RewriteRule ^index\.php$ / [R=301,L]
RewriteRule ^index/?$ / [R=301,L]

# allow with out php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \.php [NC]
RewriteRule ^(.*)\.php$ /$1 [R=301,L]



# remove query string
RewriteCond %{QUERY_STRING} .+
RewriteRule ^(.*)$ /$1? [R=301,L]

# # Handle 404 
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ /404 [R=301,L]



<FilesMatch "^\.">
    Order allow,deny
    Deny from all
</FilesMatch>

Options -Indexes


# 404 handling with custom error page
ErrorDocument 404 /404.php

<Files 403.shtml>
order allow,deny
allow from all
</Files>

deny from 43.173.179.196
deny from 43.173.176.194
deny from 43.173.180.120
deny from 43.173.179.226
deny from 240d:c010:0162:0001:0000:0000:0000:002d
deny from 43.173.181.78
