Forum Moderators: phranque
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /var/www/html/ftp_main/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html/ftp_main/upload/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/ftp_main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html/ftp_main">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
</VirtualHost>
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
RewriteEngine on
RewriteCond $1 !^FOO/
RewriteCond %{REMOTE_USER} ^FOO$
RewriteRule (.*) /var/www/html/ftp_main/upload/ [L]
[edited by: not2easy at 1:30 pm (utc) on Apr 5, 2020]
[edit reason] 'FOO' anonymized for privacy [/edit]
after login user redirected to their directory
:
RewriteCond $1 !^FOO/
RewriteCond %{REMOTE_USER} ^FOO$
RewriteRule (.*) /var/www/html/ftp_main/upload/ [L]
<Directory /var/www/html/ftp_main/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html/ftp_main/upload/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
You also appear to be duplicating the HTTP authentication block in both your vHost and .htaccess?A head-scratcher, for sure. If it is your own server and you have access to the config file, why is there an htaccess at all?
managed to do redirects to user dir but i cant download files from it or change to subdir
It's not clear from this what you actually want to do with the requested URL-path, but it looks like you need to include "FOO" in the substitution string at the start of the public URL-path.
In .htaccess you shouldn't be including the absolute filesystem path as part of the substitution.
You also appear to be duplicating the HTTP authentication block in both your vHost and .htaccess?
why is there an htaccess at all?
In .htaccess you shouldn't be including the absolute filesystem path as part of the substitution.
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
RewriteEngine on
RewriteCond $1 !^user01/
RewriteCond %{REMOTE_USER} ^user01$
RewriteRule (.*) /var/www/html/ftp_main/upload/user01/$1 [L]
RewriteCond $1 !^user02/
RewriteCond %{REMOTE_USER} ^user02$
RewriteRule (.*) /var/www/html/ftp_main/upload/user02/$1 [L]
RewriteCond $1 !^user03/
RewriteCond %{REMOTE_USER} ^user03$
RewriteRule (.*) /var/www/html/ftp_main/upload/user03/$1 [L]
DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /var/www/html/ftp_main/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html/ftp_main/upload/user01/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html/ftp_main/upload/use02/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html/ftp_main/upload/user03/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/ftp_main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html/ftp_main">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /etc/apache2/.htpasswd
Require valid-user
</Directory>
</VirtualHost>