Posts

Showing posts with the label url-rewriting

htaccess rewrite subdirectory as root and also redirect if the subdirectory is accessed directly

htaccess rewrite subdirectory as root and also redirect if the subdirectory is accessed directly https://example.com/public https://example.com/public/faq.php https://example.com https://example.com/faq.php RewriteEngine On Options +FollowSymLinks RewriteRule ^$ public/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ public/$1 [L] This rule works very well but it doesn't redirect if someone access "https://example.com/public/" or "https://example.com/public/faq.php" I have found a workaround for this. I have added below code to redirect if the public directory will be accessed directly. RewriteCond %{THE_REQUEST} /public [NC] RewriteRule .* / [L,R] Please read Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining...