How can I use the [L] RewriteRule (.htaccess) flag?

For beginners: trying to comprehensively describe my problem and talk about my questions, I produced a huge amount of text. If you do not want to read all this, my observations (read the "proof") [L]flag does not work misconception, from which all this happened, is in Additional observations . Why I misunderstood the obvious behavior is described in my answer, as well as a solution to this problem.

Customization


I have the following code in my .htaccess file:

# disallow directory indexing
Options -Indexes

# turn mod_rewrite on
Options +FollowSymlinks
RewriteEngine on

# allow access to robots file
RewriteRule ^robots.txt$ robots.txt [NC,L]

# mangle core request handler address
RewriteRule ^core/(\?.+)?$ core/handleCoreRequest.php$1 [NC,L]

# mangle web file adresses (move them to application root folder)
# application root folder serves as application GUI address
RewriteRule ^$ web/index.html [L]
# allow access to images
RewriteRule ^(images/.+\.(ico|png|bmp|jpg|gif))$ web/$1 [NC,L]
# allow access to stylesheets
RewriteRule ^(css/.+\.css)$ web/$1 [NC,L]
# allow access to javascript
RewriteRule ^(js/.+\.js)$ web/$1 [NC,L]
# allow access to library scripts, styles and images
RewriteRule ^(lib/js/.+\.js)$ web/$1 [NC,L]
RewriteRule ^(lib/css/.+\.css)$ web/$1 [NC,L]
RewriteRule ^(lib/(.+/)?images/.+\.(ico|png|bmp|jpg|gif))$ web/$1 [NC,L]

# redirect all other requests to application address
# RewriteRule ^(.*)$ /foo/ [R]

- ( .htaccess) foo DOCUMENT_ROOT ( http://localhost/foo/). PHP, foo/core GUI JavaScript, foo/web. , script, GUI "" ( ).



, , . , ..

, , , ( , , ), (Firefox - " isn ' t " ), http://localhost/foo/ , .

, , - :

RewriteRule ^$ web/index.html [L],

, [L]. , -, . , , , , [L]. - ?

, , , :

RewriteEngine on
RewriteRule ^core/(\?.+)?$ core/handleCoreRequest.php$1 [NC,L]
RewriteRule ^(.*)$ web/$1 [L]
RewriteRule ^.*$ /foo/ [L]

. , - . , ?

, - , . , , .



, bbadour ( , , , , ), , . :

RewriteRule ^(.*)$ /foo/?uri=$1 [R,L]

RewriteRule ^(.*)$ /foo/?uri=%{REQUEST_URI} [R,L]

Firebug Net, , [L] , , RewriteRule ^$ web/index.html [L] ( ). [...]uri=web/index.html, [...]uri=/foo/web/index.html. , ( ^ $ web/index.html), . , ?

+5
3

. , - , .


.htaccess ( [R]),

, RewriteRule ^$ web/index.html [L] mod_rewrite , , /foo/web/index.html, , .htaccess , . /foo/ ( [R], )... .htaccess , , ...

: , , [L] , . .htaccess , /foo/ /foo/web/index.html.



, . THE_REQUEST :

RewriteCond %{THE_REQUEST} ^GET\ /foo/web/
RewriteRule ^web/(.*) /foo/$1 [L,R]

, . -, " URI" web/ ( URI /foo/web/). -, URI /foo/web/. , , web/ , .

(soft)

RewriteCond $1 !^web/
RewriteCond $1 ^(.+\.(html|css|js|ico|png|bmp|jpg|gif))?$
RewriteRule ^(.*)$ web/$1 [L,NC]

, , , . . , , , , 404, .

RewriteRule !^web/ /foo/ [L,R]

URI, web/ ( , , web/ , .



, "" , :

# disallow directory indexing
Options -Indexes

# turn mod_rewrite on
Options +FollowSymlinks
RewriteEngine on

# allow access to robots file
RewriteRule ^robots.txt$ - [NC,L]

# mangle core request handler address
# disallow direct access to core request handler
RewriteCond %{THE_REQUEST} !^(GET|POST)\ /asm/core/handleCoreRequest.php
RewriteRule ^core/handleCoreRequest.php$ - [L]
# allow access to request handler under alias
RewriteRule ^core/$ core/handleCoreRequest.php [NC,QSA,L]

# mangle GUI files adressing (move to application root folder)
# disallow direct access to GUI subfolder
RewriteCond %{THE_REQUEST} ^GET\ /foo/web/
RewriteRule ^web/(.*) /foo/$1 [L,R]
# allow access only to correct filetypes in appropriate locations
RewriteCond $1 ^$ [OR]
RewriteCond $1 ^(images/.+\.(ico|png|bmp|jpg|gif))$ [OR]
RewriteCond $1 ^(css/.+\.css)$ [OR]
RewriteCond $1 ^(js/.+\.js)$ [OR]
RewriteCond $1 ^(lib/js/.+\.js)$ [OR]
RewriteCond $1 ^(lib/css/.+\.css)$ [OR]
RewriteCond $1 ^(lib/(.+/)?images/.+\.(ico|png|bmp|jpg|gif))$
RewriteRule ^(.*)$ web/$1 [L,NC]

# hide all files not in GUI subfolder that are not whitelisted above
RewriteRule !^web/ /foo/ [L,R]


, , .htaccess( ), , .

+12

, URL-, ( URL-, ), , , , URL- , , .

0

:

RewriteRule ^(.*)$ /foo/ [R,L]

, RewriteCond, , /foo/

0

All Articles