You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2016/08/01 11:44:55 UTC

[Bug 59921] New: Only the last Directory directive with same path is processed

https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

            Bug ID: 59921
           Summary: Only the last Directory directive with same path is
                    processed
           Product: Apache httpd-2
           Version: 2.4.23
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
          Assignee: bugs@httpd.apache.org
          Reporter: viktor@szepe.net

Core doc says:

If multiple (non-regular expression) <Directory> sections match the directory
(or one of its parents) containing a document, then the directives are applied
in the order of shortest match first, interspersed with the directives from the
.htaccess files.

I have two Directory directives with the same path (in realty the second one is
in an Include that is used by all vhost configs)


Request URI:
http://subtwo.wp/blog/

My config:
    DocumentRoot "/var/www/subtwo/2"
    <Directory "/var/www/subtwo/2">
        # Core permalinks
        RewriteRule "^index\.php$" - [END]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule "^" "index.php" [END]
    </Directory>

    <Directory "/var/www/subtwo/2">
        RewriteRule "^blog/$" "/some-url"
    </Directory>

End up in /some-url:
init rewrite engine with requested uri /blog/
pass through /blog/
[perdir /var/www/subtwo/2/] add path info postfix: /var/www/subtwo/2/blog ->
/var/www/subtwo/2/blog/
[perdir /var/www/subtwo/2/] strip per-dir prefix: /var/www/subtwo/2/blog/ ->
blog/
[perdir /var/www/subtwo/2/] applying pattern '^blog/$' to uri 'blog/'
[perdir /var/www/subtwo/2/] rewrite 'blog/' -> '/some-url'
[perdir /var/www/subtwo/2/] trying to replace context docroot /var/www/subtwo/2
with context prefix
[perdir /var/www/subtwo/2/] internal redirect with /some-url [INTERNAL
REDIRECT]

/redir#1] init rewrite engine with requested uri /some-url
/redir#1] pass through /some-url
/redir#1] [perdir /var/www/subtwo/2/] strip per-dir prefix:
/var/www/subtwo/2/some-url -> some-url
/redir#1] [perdir /var/www/subtwo/2/] applying pattern '^blog/$' to uri
'some-url'
/redir#1] [perdir /var/www/subtwo/2/] pass through /var/www/subtwo/2/some-url


The other way around:

Config:
    DocumentRoot "/var/www/subtwo/2"
    <Directory "/var/www/subtwo/2">
        RewriteRule "^blog/$" "/some-url"
    </Directory>

    <Directory "/var/www/subtwo/2">
        # Core permalinks
        RewriteRule "^index\.php$" - [END]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule "^" "index.php" [END]
    </Directory>

Ends up in /index.php:
init rewrite engine with requested uri /blog/
pass through /blog/
[perdir /var/www/subtwo/2/] add path info postfix: /var/www/subtwo/2/blog ->
/var/www/subtwo/2/blog/
[perdir /var/www/subtwo/2/] strip per-dir prefix: /var/www/subtwo/2/blog/ ->
blog/
[perdir /var/www/subtwo/2/] applying pattern '^index\\.php$' to uri 'blog/'
[perdir /var/www/subtwo/2/] add path info postfix: /var/www/subtwo/2/blog ->
/var/www/subtwo/2/blog/
[perdir /var/www/subtwo/2/] strip per-dir prefix: /var/www/subtwo/2/blog/ ->
blog/
[perdir /var/www/subtwo/2/] applying pattern '^' to uri 'blog/'
[perdir /var/www/subtwo/2/] RewriteCond: input='/var/www/subtwo/2/blog'
pattern='!-f' => matched
[perdir /var/www/subtwo/2/] RewriteCond: input='/var/www/subtwo/2/blog'
pattern='!-d' => matched
[perdir /var/www/subtwo/2/] rewrite 'blog/' -> 'index.php'
[perdir /var/www/subtwo/2/] add per-dir prefix: index.php ->
/var/www/subtwo/2/index.php
[perdir /var/www/subtwo/2/] strip document_root prefix:
/var/www/subtwo/2/index.php -> /index.php
[perdir /var/www/subtwo/2/] internal redirect with /index.php [INTERNAL
REDIRECT]


Is this behavior just undocumented or buggy?
Thans.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule cannot be made to inherit the matching Directory directive rules in .htaccess files

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

Ruediger Pluem <rp...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|APIBug                      |

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule cannot be made to inherit the matching Directory directive rules in .htaccess files

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

--- Comment #6 from Viktor Szépe <vi...@szepe.net> ---
A strange (for me at least) fact is:

Rewrite order is:

DirectoryMatch -> .htaccess -> Directory

But if any of these matches - regardless of [L] or [END] - rewrite processing
stops there.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule cannot be made to inherit the matching Directory directive rules in .htaccess files

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

Viktor Szépe <vi...@szepe.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|RewriteRule is processed    |RewriteRule cannot be made
                   |only in the last Directory  |to inherit the matching
                   |directive with same path    |Directory directive rules
                   |                            |in .htaccess files

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule is processed only in the last Directory directive with same path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

Eric Covener <co...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from Eric Covener <co...@gmail.com> ---
Does RewriteOptions Inherit change the behavior?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule is processed only in the last Directory directive with same path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

--- Comment #3 from Szépe Viktor <vi...@szepe.net> ---
(In reply to Eric Covener from comment #2)
> Does RewriteOptions Inherit change the behavior?

Thank you very much for your comment.
It solved the two Directory directives problem.

I've noticed that the .htaccess in the same directory overrides the rewite
rules.
I've tried placing RewriteOptions Inherit into the .htaccess file at several
places with no success.
Could it be solved somehow?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule is processed only in the last Directory directive with same path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

--- Comment #4 from Eric Covener <co...@gmail.com> ---
(In reply to Szépe Viktor from comment #3)
> (In reply to Eric Covener from comment #2)
> > Does RewriteOptions Inherit change the behavior?
> 
> Thank you very much for your comment.
> It solved the two Directory directives problem.
> 
> I've noticed that the .htaccess in the same directory overrides the rewite
> rules.
> I've tried placing RewriteOptions Inherit into the .htaccess file at several
> places with no success.
> Could it be solved somehow?

I would have thought it would behave the same -- the htaccess rules replace the
matching <Directory> rules unless you tell it to inherit in that
rewrite-specific way.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule is processed only in the last Directory directive with same path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

Szépe Viktor <vi...@szepe.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Only the last Directory     |RewriteRule is processed
                   |directive with same path is |only in the last Directory
                   |processed                   |directive with same path

--- Comment #1 from Szépe Viktor <vi...@szepe.net> ---
https://httpd.apache.org/docs/2.4/sections.html also says:

If multiple <Directory> sections apply to the same directory they are processed
in the configuration file order.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule is processed only in the last Directory directive with same path

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

Szépe Viktor <vi...@szepe.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule cannot be made to inherit the matching Directory directive rules in .htaccess files

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

--- Comment #5 from Viktor Szépe <vi...@szepe.net> ---
> I would have thought it would behave the same -- the htaccess rules replace
> the matching <Directory> rules unless you tell it to inherit in that
> rewrite-specific way.

Thank you again.

A temporary word-aroung could be to use the DirectoryMatch directive as it will
surely override directory rules.
http://httpd.apache.org/docs/2.4/sections.html#merging

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59921] RewriteRule cannot be made to inherit the matching Directory directive rules in .htaccess files

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59921

raj <vr...@dikitin.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://www.baliapur.com/
           Keywords|                            |APIBug

--- Comment #7 from raj <vr...@dikitin.com> ---
<a
href="https://www.baliapur.com/2021/10/what-is-ott-platform-full-information-in-hindi.html">ओटीटी
प्लेटफॉर्म क्या है</a> 

<a href="https://www.baliapur.com/2021/10/wifi-calling-kaise-kare.html">[WiFi
Calling] वाईफाई कॉलिंग क्या है : Android या iPhone पर कैसे शुरू करें?  </a> 

<a
href="https://www.baliapur.com/2021/10/facebook-ka-malik-kaun-hai-aur-kis-desh-ka-app.html">फेसबुक
का मालिक कौन है?</a> 

<a
href="https://www.baliapur.com/2021/10/how-does-truecaller-know-your-name.html">Truecaller
Safe : ट्रू कॉलर को आपका नाम कैसे पता चलता है?</a> 

<a
href="https://www.baliapur.com/2021/10/instagram-account-ko-kaise-surakshit-rakhen.html">10
आसान तरीके से अपने इंस्टाग्राम अकाउंट को सुरक्षित रखें 2021</a> 

<a
href="https://www.baliapur.com/2021/10/digital-health-id-card-ke-liye-aavedan-kaise-karen.html">डिजिटल
हेल्थ आईडी कार्ड के लिए आवेदन कैसे करें? यहाँ जाने डिटेल</a> 

<a
href="https://www.baliapur.com/2021/09/best-new-features-coming-to-whatsapp.html">WhatsApp
New Features: बेहतरीन नए फीचर बदल देंगे यूजर्स का एक्सपीरियंस</a> 

<a
href="https://www.baliapur.com/2021/09/cholesterol-kam-karne-ki-exercise.html">सबसे
आसान उपाय 5 मिनट में कोलेस्ट्रॉल कम करने की एक्सरसाइज</a> 

<a
href="https://www.baliapur.com/2021/09/internet-se-free-mein-fake-call-kaise-karen.html">इंटरनेट
से फ्री में फेक कॉल कैसे करें</a> 

<a
href="https://www.baliapur.com/2021/09/download-best-photo-editing-android-apps.html">टॉप
10+ बेस्ट फोटो एडिटिंग ऐप</a> 

<a
href="https://www.baliapur.com/2021/09/game-khel-kar-paise-kaise-kamaye.html">गेम
खेल कर पैसा कैसे कमाए [ 25+ Game ] मोबाइल से पैसे कमाने का तरीका</a> 


<a
href="https://www.baliapur.com/2021/09/simple-home-remedies-treat-dandruff-naturally.html">डैंड्रफ
का प्राकृतिक रूप से इलाज करने के 5 घरेलू उपचार</a> 


<a
href="https://www.baliapur.com/2021/09/iphone-to-android-whatsapp-chat-history-transfer.html">व्हाट्सएप
चैट हिस्ट्री को आईफोन से एंड्रॉयड में कैसे ट्रांसफर करें? जाने यह तरीका </a> 

<a
href="https://www.baliapur.com/2021/08/youtube-video-download-kaise-karen.html">यूट्यूब
और फेसबुक से वीडियो कैसे डाउनलोड करें</a>

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org