L
L
ldmitriy2019-11-14 22:40:51
htaccess
ldmitriy, 2019-11-14 22:40:51

What is the difference between REQUEST_FILENAME and REQUEST_URI in htaccess?

I have a host (site.local) and I refer to the example site.local/news/list
Where is Request_filename/request_uri?

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

RewriteEngine on
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule . index.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-11-14
@ldmitriy

httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rew...

REQUEST_FILENAME
The full local filesystem path to the file or script matching the request, if this has already been determined by the server at the time REQUEST_FILENAME is referenced. Otherwise, such as when used in virtual host context, the same value as REQUEST_URI. Depending on the value of AcceptPathInfo, the server may have only used some leading components of the REQUEST_URI to map the request to a file.
REQUEST_URI
The path component of the requested URI, such as "/index.html". This notably excludes the query string which is available as its own variable named QUERY_STRING.
Suppose the site DocumentRoot "/var/www", then when accessing site.local/news/list
%{REQUEST_FILENAME} -> /var/www/news/list
%{REQUEST_URI}      -> /news/list

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question