RewriteRule and NS Flag no-subrequest

instructs the server to skip the directive if internal sub-request.


Problem is , I am not really getting what is internal subrequest properly ,  I have gone through some apache official documentation but hard to observe it. I need to understand it for htaccess file.
Amit KumarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve BinkCommented:
An internal subrequest is a secondary request generated by Apache itself.   The subrequest goes through the normal life cycle of an external request, including handlers, mapping to the file system, and authorization/accessibility.

Internal subrequests are generated in a variety of ways, such as error documents.  In the context of mod_rewrite, the %F test for RewriteCond will generate an internal request to check for the existence of a file.  This could be necessary in cases where the end file resides in a directory which is itself the target of an alias.  Aliases are processed after rewrites, so the final file mapping will not be known until after the rewrites are already done.  By using %F, you can force Apache to start a subrequest to map the file, determine if it exists, and return information to the calling request.  Obviously, you wouldn't want those checks to go through your standard rewrites (resulting in an endless loop), so the [NS] flag is used to exempt subrequests from specific rules.

FYI, according to Apache docs, subrequests are generally not logged.  You can, however, see subrequest processing in the rewrite log.  It might be helpful to turn on the full debugging log and walk through a few requests.  I found it immensely educational.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.