简体   繁体   中英

How to allow users to access a folder, through “.htaccess”?

I created a folder in my domain, called: SquirrelMail .

I have this .htaccess :

<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On


##
## You may need to uncomment the following line for some hosting environments,
## if you have installed to a subdirectory, enter the name here also.
##
# RewriteBase /

##
## Black list protected files
##
RewriteRule ^themes/.*/(layouts|pages|partials)/.*.htm index.php [L,NC]
RewriteRule ^bootstrap/.* index.php [L,NC]
RewriteRule ^config/.* index.php [L,NC]
RewriteRule ^vendor/.* index.php [L,NC]
RewriteRule ^storage/cms/.* index.php [L,NC]
RewriteRule ^storage/logs/.* index.php [L,NC]
RewriteRule ^storage/framework/.* index.php [L,NC]
RewriteRule ^storage/temp/protected/.* index.php [L,NC]
RewriteRule ^storage/app/uploads/protected/.* index.php [L,NC]

##
## White listed folders and files
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} !\.js$
RewriteCond %{REQUEST_URI} !\.map$
RewriteCond %{REQUEST_URI} !\.ico$
RewriteCond %{REQUEST_URI} !\.jpg$
RewriteCond %{REQUEST_URI} !\.jpeg$
RewriteCond %{REQUEST_URI} !\.bmp$
RewriteCond %{REQUEST_URI} !\.png$
RewriteCond %{REQUEST_URI} !\.gif$
RewriteCond %{REQUEST_URI} !\.svg$
RewriteCond %{REQUEST_URI} !\.css$
RewriteCond %{REQUEST_URI} !\.less$
RewriteCond %{REQUEST_URI} !\.scss$
RewriteCond %{REQUEST_URI} !\.pdf$
RewriteCond %{REQUEST_URI} !\.swf$
RewriteCond %{REQUEST_URI} !\.txt$
RewriteCond %{REQUEST_URI} !\.xml$
RewriteCond %{REQUEST_URI} !\.xls$
RewriteCond %{REQUEST_URI} !\.eot$
RewriteCond %{REQUEST_URI} !\.woff$
RewriteCond %{REQUEST_URI} !\.woff2$
RewriteCond %{REQUEST_URI} !\.ttf$
RewriteCond %{REQUEST_URI} !\.flv$
RewriteCond %{REQUEST_URI} !\.wmv$
RewriteCond %{REQUEST_URI} !\.mp3$
RewriteCond %{REQUEST_URI} !\.ogg$
RewriteCond %{REQUEST_URI} !\.wav$
RewriteCond %{REQUEST_URI} !\.avi$
RewriteCond %{REQUEST_URI} !\.mov$
RewriteCond %{REQUEST_URI} !\.mp4$
RewriteCond %{REQUEST_URI} !\.mpeg$
RewriteCond %{REQUEST_URI} !\.webm$
RewriteCond %{REQUEST_URI} !\.mkv$
RewriteCond %{REQUEST_URI} !\.rar$
RewriteCond %{REQUEST_URI} !\.zip$
RewriteCond %{REQUEST_URI} !docs/.*
RewriteCond %{REQUEST_URI} !themes/.*
RewriteRule ^ index.php [L,NC]

##
## Standard routes
##
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Everytime, I go to: mydomain.com/squirrelmail , I am getting a Page Not Found error.

What should I have in my .htaccess in order for me to access my SquirrelMail folder?

Your help will be greatly appreciated!

The .htaccess is an octoberCMS default. I wanted to install SquirrelMail by creating a folder. I do not have access on a sub-domain that is why I did it like that.

October's .htaccess file in the stable release uses a newer approach, more friendly to your requirements. See the new white list approach below:

##
## White listed folders
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !/storage/app/uploads/.*
RewriteCond %{REQUEST_FILENAME} !/storage/app/media/.*
RewriteCond %{REQUEST_FILENAME} !/storage/temp/public/.*
RewriteCond %{REQUEST_FILENAME} !/themes/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/plugins/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/modules/.*/(assets|resources)/.*
RewriteRule !^index.php index.php [L,NC]

Simply add a new line for your folder, that should allow all files through.

RewriteCond %{REQUEST_FILENAME} !/myfolder/.*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM