Restricting A Directory Through .htaccess
Posted
by
Whitechapel
on Pro Webmasters
See other posts from Pro Webmasters
or by Whitechapel
Published on 2013-10-20T18:56:57Z
Indexed on
2013/10/20
22:12 UTC
Read the original article
Hit count: 188
htaccess
I'm trying to put all of my FTP accounts into a folder on /public_html/ftp and password protect it so search bots can't crawl their private files. I'm also trying to redirect all site traffic from the non-www to www. I keep getting 500 errors when accessing the site, and I need to point it to www.vivalanation.com/ftp to www.vivalanation.com/ftp/, because the /ftp just errors out, you need the trailing slash.
Here is my .htaccess in the /public_html/ftp folder:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
AuthName "FTP Access"
AuthType Basic
AuthUserFile /home1/vivalst/.htpasswds/public_html/ftp/passwd Require valid-user
I created a passwd file in /.htpasswds/public_html/ftp
And here is my basic .htaccess in the root of /public_html/:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
© Pro Webmasters or respective owner