A
A
Amina2019-09-25 21:53:20
htaccess
Amina, 2019-09-25 21:53:20

Why doesn't the .htaccess exception work?

Good night, tell me why the exception in the ..htaccess file does not work

RewriteEngine On
RewriteRule .* index.php
RewriteCond %{REQUEST_URI} !^/event/
RewriteCond %{HTTP:X-Forwarded-proto} !^https$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

In the event folder there is a test.php file that outputs a string, but when I click on the link https//mysite/event/test.php I see a white screen - what's the problem?
And in the same folder there is a php script, which is launched via cron and everything works fine.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-09-25
@dodo512

The request is compared one by one with the templates in the RewriteRule and the first match is redirected.
First rule RewriteRule .* index.php
The pattern .*matches any string, so the request /event/test.phpwill be redirected to index.php at the root of the site.

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-proto} !^https$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

Probably running php cli directly in cron rather than request via webserver.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question