Open tobiasschaeferptb opened 2 years ago
(reworked the ticket to make it readable with some new lines, some code formatting)
The RewriteCond
should probably better be !^/fileadmin/......
in the first place, for a root installation, but for sure the RewriteRule
cannot wrong for a subdirectory since it reads:
RewriteRule ^fileadmin/.*$ %{ENV:CWD}index.php [QSA,L]
The ^
stands for "beginning of the string". And if you are in a subdirectory, then obviously there will be some prefix there.
In case of having a subdirectory, you probably want to either adapt the proposed rules or make use of the RewriteBase
instructions in addition. See https://stackoverflow.com/questions/11784073/apache-rewrite-rule-to-redirect-all-request-to-subdirectory-containing-another for an example.
Please comment if this works and possibly what you changed so that it works (useful for others coming to this ticket in future).
The RewriteRule seems to work as it is. TYPO3 (10.4.25) throws as exception at the end of the matchRequest method in typo3/sysext/core/Classes/Routing/PageRouter.php at line 227
throw new RouteNotFoundException('No route found for path "' . $urlPath . '"', 1538389998);
The $urlPath variable contains the path to the file and the filename without the subdirectory abc:
fileadmin/test.pdf
The request was https://hostname2.xz/abc/fileadmin/test.pdf. So I think $urlPath should be abc/fileadmin/test.pdf.
I tried to get the backtrace with debug_print_backtrace. This is what I got:
Then Chrome crashed because of out of memory.
@tobiasschaeferptb Did you try to adapt the .htacccess
rule to
RewriteCond %{REQUEST_URI} !/abc/fileadmin/_processed_/.*$
RewriteRule ^abc/fileadmin/.*$ %{ENV:CWD}index.php [QSA,L]
as suggested?
I tested
RewriteCond %{REQUEST_URI} !/abc/fileadmin/_processed_/.*$
RewriteRule ^abc/fileadmin/.*$ %{ENV:CWD}index.php [QSA,L]
and
RewriteCond %{REQUEST_URI} !^/abc/fileadmin/_processed_/.*$
RewriteRule ^abc/fileadmin/.*$ %{ENV:CWD}index.php [QSA,L]
as you suggested on Feb 28, 2022 that it should be !^/abc/fileadmin/_processed_/.*$
instead of !/abc/fileadmin/_processed_/.*$
. Both didn't work. I also updated to v1.4.1.
Is the order of the 2 RewriteCond
important?
RewriteCond %{REQUEST_URI} !^/abc/fileadmin/_processed_/.*$
RewriteRule ^abc/fileadmin/.*$ %{ENV:CWD}index.php [QSA,L]
RewriteCond %{REQUEST_URI} !^/fileadmin/_processed_/.*$
RewriteRule ^fileadmin/.*$ %{ENV:CWD}index.php [QSA,L]
or
RewriteCond %{REQUEST_URI} !^/fileadmin/_processed_/.*$
RewriteRule ^fileadmin/.*$ %{ENV:CWD}index.php [QSA,L]
RewriteCond %{REQUEST_URI} !^/abc/fileadmin/_processed_/.*$
RewriteRule ^abc/fileadmin/.*$ %{ENV:CWD}index.php [QSA,L]
With both orders it only works with https://hostname1.xz/fileadmin/test.pdf.
Have you tried setting the RewriteBase
property to /abc/
in the .htaccess
file?
What would be the right combination of RewriteBase, RewriteCond and RewriteRule? If I use RewriteBase /abc/ follow by RewriteCond and RewriteRule do I have to set the RewriteBase to / afterwards?
I don't use Apache on any production server, so I won't help.
@tobiasschaeferptb: Hint: since I already edited two of your messages to be more readable, please use single backtick (`) and triple backticks (```) when showing some code and code block respectively as it makes reading much more pleasant for everyone. And If you write multiple paragraphs, then please add an empty line between them, for the same reason.
Hi,
I can't get it to work if the TYPO3 installation is located in a subdirectory of the apache root directory. I would like to be able use fal_protect if the same file can be accessed with: https://hostname1.xz/fileadmin/test.pdf
and https://hostname2.xz/abc/fileadmin/test.pdf
hostname1.xzpoints to TYPO3 root directory (
/srv/www/htdocs/abc) and
hostname2to the apache root directory (
/srv/www/htdocs`).If I use this in
/srv/www/htdocs/abc/.htaccess
:it works for https://hostname1.xz/fileadmin/test.pdf but it doesn't work for https://hostname2.xz/abc/fileadmin/test.pdf
TYPO3 error message:
Page Not Found The page did not exist or was inaccessible. Reason: The requested page does not exist
How do I have to change the RewriteRule to make it work?
Cheers, Tobias