htaccess clean URLs while still protecting a subdirectory
If you use clean URLs (SEO friendly) and also want to protect a folder, this is what you put in the .htaccess file in the /public_html folder. In this example everything that does not exist is redirected to index.php. The line with 401.shtml is important for the protected directory. 401 is the code for Authorization required and must be caught for this to work.
#SEO modification
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(401.shtml)
RewriteRule ^(.*)$ index.php [L,QSA]
Was this article helpful?
