C
C
Cat Anton2014-10-31 00:32:53
Apache HTTP Server
Cat Anton, 2014-10-31 00:32:53

How does htaccess ZendSkeletonApplication work?

I'm trying to understand how the ZendSkeletonApplication .htaccess file works
https://github.com/zendframework/ZendSkeletonAppli...
If everything is clear with the first part of it, then the opposite is true with the second.

# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

I would appreciate a detailed answer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
ugodrus, 2014-10-31
@27cm

RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

In short, it's a fancy /directory/application/method request construct built to calculate the base startup directory.
In the first line pattern itself ^(/directory)(used method)::{link to the method used from the same regularizer} and modifying the original %{REQUEST_URI} suffix.
In the second line ^(/directory) is written to the environment
In the third line the request is redirected to /directory/index.php
Although I don't see the point in the second line. It would be more appropriate to somehow pass the method used to the script as a separate variable.
I would do it easier:
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*)$ %1index.php [NC,L]

Although (maybe I'm wrong) you can do this: RewriteCond %{REQUEST_URI}::$2 ^(/.+/)(.+)::\2$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question