Welcome Guest, Not a member yet? Register   Sign In
Restrict access to files in public subfolder with httpd mod_rewrite
#1

(This post was last modified: 07-19-2022, 07:34 AM by eelisland.)

Hi,
I have installed CI4 in a subfolder /test/ following This post

Using rewritemap and CI4 i'm trying to:
- give access to file in folder if query string value exist in map file
- disable access if query string value is empty or no query string at all

Actually everything bellow work if filename don't have space in name, anyway i should do something wrong since when url with filename with space (%20) CI thought it is a controller and gave me a 404 controller not found.
My guess is that my rewritemap is not at the right place.

This is the configurattion that i use.

httpd-ssl.conf

Code:
RewriteEngine On

# Rewritemap:
RewriteMap filehash txt:file_hash.txt

# Query string equal to key=digits lookup in map
# redirect to /404 on fail else redirect to match in map
RewriteCond %{QUERY_STRING} ^(key=)([0-9]*)
RewriteRule ^/test/video/(.*)$ ${filehash:%2|/404}? [PT,NE,L]

# Query string empty: key=
RewriteCond %{QUERY_STRING} !^key=+$
RewriteRule ^/test/video/(.*)$ - [R=404,L]

# Empty query string
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/test/video/(.*)$ - [R=404,L]

Map file_hash.txt

Code:
1001 /test/video/london_bridge_footage.mp4
1002 /test/video/london bridge footage.mp4
1003 /test/video/london%20bridge%20footage.mp4
1004 /test/video/london\ bridge\ footage.mp4

httpd.conf

Code:
<Directory "/var/www/test">
  LogLevel alert rewrite:trace6
  DirectoryIndex index.php
  AllowOverride All
  Require all granted
</Directory>

.htaccess in /test/ CI4 folder

Code:
# Disable directory browsing
Options All -Indexes

# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

# If you installed CodeIgniter in a subfolder, you will need to
# change the following line to match the subfolder you need.
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
RewriteBase /test

# Rewrite CSS / JS "theme.1603357209.css -> theme.css"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.\d+(\.(?:js|css))$ $1$2

# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

# Rewrite "www.example.com -> example.com"
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

# Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

# Ensure Authorization header is passed along
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Updating my post with rewritelog

in map file: 
Code:
1003 /test/video/london%20bridge%20footage.mp4
should work but CI4 treat url like if it's a controller and not a file, there seems to be something wrong where i put my rewritemap configuration that interfer with CI4 .htaccess, i've been searching for hours now and i'm stuck.

Code:
[Mon Jul 18 22:32:19.837894 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/video/london%20bridge%20footage.mp4 -> video/london%20bridge%20footage.mp4
[Mon Jul 18 22:32:19.837918 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] applying pattern '^(.+)\\.\\d+(\\.(?:js|css))$' to uri 'video/london%20bridge%20footage.mp4'
[Mon Jul 18 22:32:19.837924 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/video/london%20bridge%20footage.mp4 -> video/london%20bridge%20footage.mp4
[Mon Jul 18 22:32:19.837927 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] applying pattern '^' to uri 'video/london%20bridge%20footage.mp4'
[Mon Jul 18 22:32:19.837942 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/video/london%20bridge%20footage.mp4 -> video/london%20bridge%20footage.mp4
[Mon Jul 18 22:32:19.837945 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] applying pattern '^' to uri 'video/london%20bridge%20footage.mp4'
[Mon Jul 18 22:32:19.837948 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/video/london%20bridge%20footage.mp4 -> video/london%20bridge%20footage.mp4
[Mon Jul 18 22:32:19.837951 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] applying pattern '^([\\s\\S]*)$' to uri 'video/london%20bridge%20footage.mp4'
[Mon Jul 18 22:32:19.837956 2022] [rewrite:trace2] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] rewrite 'video/london%20bridge%20footage.mp4' -> 'index.php/video/london%20bridge%20footage.mp4'
[Mon Jul 18 22:32:19.837966 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] add per-dir prefix: index.php/video/london%20bridge%20footage.mp4 -> /var/www/test/index.php/video/london%20bridge%20footage.mp4
[Mon Jul 18 22:32:19.837970 2022] [rewrite:trace2] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] trying to replace prefix /var/www/test/ with /test
[Mon Jul 18 22:32:19.837973 2022] [rewrite:trace1] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40128a0/initial] [perdir /var/www/test/] internal redirect with /test/index.php/video/london%20bridge%20footage.mp4 [INTERNAL REDIRECT]
[Mon Jul 18 22:32:19.838010 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] add path info postfix: /var/www/test/index.php -> /var/www/test/index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838015 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/index.php/video/london bridge footage.mp4 -> index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838018 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] applying pattern '^(.+)\\.\\d+(\\.(?:js|css))$' to uri 'index.php/video/london bridge footage.mp4'
[Mon Jul 18 22:32:19.838022 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] add path info postfix: /var/www/test/index.php -> /var/www/test/index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838025 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/index.php/video/london bridge footage.mp4 -> index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838027 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] applying pattern '^' to uri 'index.php/video/london bridge footage.mp4'
[Mon Jul 18 22:32:19.838046 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] add path info postfix: /var/www/test/index.php -> /var/www/test/index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838049 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/index.php/video/london bridge footage.mp4 -> index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838054 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] applying pattern '^' to uri 'index.php/video/london bridge footage.mp4'
[Mon Jul 18 22:32:19.838057 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] add path info postfix: /var/www/test/index.php -> /var/www/test/index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838062 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/index.php/video/london bridge footage.mp4 -> index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838065 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] applying pattern '^([\\s\\S]*)$' to uri 'index.php/video/london bridge footage.mp4'
[Mon Jul 18 22:32:19.838070 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] add path info postfix: /var/www/test/index.php -> /var/www/test/index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838074 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/index.php/video/london bridge footage.mp4 -> index.php/video/london bridge footage.mp4
[Mon Jul 18 22:32:19.838076 2022] [rewrite:trace3] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] applying pattern '.*' to uri 'index.php/video/london bridge footage.mp4'
[Mon Jul 18 22:32:19.838081 2022] [rewrite:trace1] [pid 26391:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400cc00/initial/redir#1] [perdir /var/www/test/] pass through /var/www/test/index.php
[Mon Jul 18 22:32:20.061135 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.1658174761.js -> assets/dist/js/theme.1658174761.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061153 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] applying pattern '^(.+)\\.\\d+(\\.(?:js|css))$' to uri 'assets/dist/js/theme.1658174761.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061170 2022] [rewrite:trace2] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] rewrite 'assets/dist/js/theme.1658174761.js' -> 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061174 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] add per-dir prefix: assets/dist/js/theme.js -> /var/www/test/assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061177 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.js -> assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061180 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] applying pattern '^' to uri 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061197 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.js -> assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061201 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] applying pattern '^' to uri 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061205 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.js -> assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061208 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] applying pattern '^([\\s\\S]*)$' to uri 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061213 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.js -> assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061217 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] applying pattern '.*' to uri 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061225 2022] [rewrite:trace2] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] trying to replace prefix /var/www/test/ with /test, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061228 2022] [rewrite:trace1] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f4017a10/initial] [perdir /var/www/test/] internal redirect with /test/assets/dist/js/theme.js [INTERNAL REDIRECT], referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061246 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.js -> assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061251 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] applying pattern '^(.+)\\.\\d+(\\.(?:js|css))$' to uri 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061255 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.js -> assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061258 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] applying pattern '^' to uri 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061271 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.js -> assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061275 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] applying pattern '^' to uri 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061278 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.js -> assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061281 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] applying pattern '^([\\s\\S]*)$' to uri 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061289 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/assets/dist/js/theme.js -> assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061293 2022] [rewrite:trace3] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] applying pattern '.*' to uri 'assets/dist/js/theme.js', referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003
[Mon Jul 18 22:32:20.061299 2022] [rewrite:trace1] [pid 26391:tid 140071791121984] mod_rewrite.c(486): [client 192.168.1.254:42862] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f400b7d0/initial/redir#1] [perdir /var/www/test/] pass through /var/www/test/assets/dist/js/theme.js, referer: https://my-domain.org/test/video/london%20bridge%20footage.mp4?key=1003


rewriterule is making INTERNAL REDIRECT, maybe it is there that the problem occur.



In map file the line
Code:
1001 /test/video/london_bridge_footage.mp4
work as expected.

Code:
[Mon Jul 18 22:28:44.436405 2022] [core:notice] [pid 2002:tid 140071990364096] AH00094: Command line: '/usr/sbin/httpd'
[Mon Jul 18 22:28:49.518993 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/video/london_bridge_footage.mp4 -> video/london_bridge_footage.mp4
[Mon Jul 18 22:28:49.519018 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] applying pattern '^(.+)\\.\\d+(\\.(?:js|css))$' to uri 'video/london_bridge_footage.mp4'
[Mon Jul 18 22:28:49.519025 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/video/london_bridge_footage.mp4 -> video/london_bridge_footage.mp4
[Mon Jul 18 22:28:49.519045 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] applying pattern '^' to uri 'video/london_bridge_footage.mp4'
[Mon Jul 18 22:28:49.519060 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/video/london_bridge_footage.mp4 -> video/london_bridge_footage.mp4
[Mon Jul 18 22:28:49.520125 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] applying pattern '^' to uri 'video/london_bridge_footage.mp4'
[Mon Jul 18 22:28:49.520143 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/video/london_bridge_footage.mp4 -> video/london_bridge_footage.mp4
[Mon Jul 18 22:28:49.520146 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] applying pattern '^([\\s\\S]*)$' to uri 'video/london_bridge_footage.mp4'
[Mon Jul 18 22:28:49.520161 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] strip per-dir prefix: /var/www/test/video/london_bridge_footage.mp4 -> video/london_bridge_footage.mp4
[Mon Jul 18 22:28:49.520165 2022] [rewrite:trace3] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] applying pattern '.*' to uri 'video/london_bridge_footage.mp4'
[Mon Jul 18 22:28:49.520170 2022] [rewrite:trace1] [pid 26321:tid 140071799514688] mod_rewrite.c(486): [client 192.168.1.254:42860] 192.168.1.254 - - [my-domain.org/sid#5561d7dc23b8][rid#7f64f40139e0/initial] [perdir /var/www/test/] pass through /var/www/test/video/london_bridge_footage.mp4



help appreciated.

Thanks
Reply


Messages In This Thread
Restrict access to files in public subfolder with httpd mod_rewrite - by eelisland - 07-18-2022, 11:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB