RewritEengine on
Options +FollowSymlinks
DirectoryIndex main.php
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://martlet.lexaplus.ir/$1 [r=301,nc]
RewriteRule ^main\.php - [L]
#if other php file called(user typed it in), redirect to extensionless uri
RewriteCond %{THE_REQUEST} ^GET\ /(.+)\.php
RewriteRule ^ /%1? [R=302,L]
#if extensionless uri maps to a real php file, forward to main.php
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [OR]
#or if not a real file or directory forward to main.php
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([\s\S]*)$ main.php [L,NC,B]