D
D
DYLAN2020-11-16 13:12:54
Apache HTTP Server
DYLAN, 2020-11-16 13:12:54

Why does a 301 redirect result in a double script execution?

Perhaps the question is stupid, but I have never paid attention to this before, please clarify =)
In general, I use docker for WP, I took the image from here https://hub.docker.com/_/wordpress

Apache and
.htaccess redirects are already configured there


# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress`
# are created automatically and can only be changed through WordPress filters.
# Manual changes between these markers will be overwritten.

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


# END WordPress


However, if you make a request to a page, for example, localhost/index.php , and use xdebug for debugging (well, or just write something to a file), put a breakpoint in index.php, you will notice that the script runs 2 times, although according to the idea 301 redirect should not lead to the execution of the page code, or should it? The browser will immediately cache this redirect, so you should always flush the cache or use wget or tulnet.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question