admin管理员组

文章数量:1124655

folder structure

docroot
  |- wordpress
     |- web.config 
     |- wp-content
        |- japi
           |- index.php
           \- web.config
     ...
  ...

As you can see there are 2 web.config s. One in the wordpress folder and one in wordpress/wp-content/japi folder.

japi/web.config

  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
    </rule>
  </rules>

Now when I request for . The japi/web.config seems to be neglected and only wordpress/web.config is being considered.

How can I fix this ?

folder structure

docroot
  |- wordpress
     |- web.config 
     |- wp-content
        |- japi
           |- index.php
           \- web.config
     ...
  ...

As you can see there are 2 web.config s. One in the wordpress folder and one in wordpress/wp-content/japi folder.

japi/web.config

  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
    </rule>
  </rules>

Now when I request for http://domain.com/wordpress/wp-content/japi/test. The japi/web.config seems to be neglected and only wordpress/web.config is being considered.

How can I fix this ?

Share Improve this question edited Jan 13, 2014 at 14:32 Prakash Raman asked Jan 13, 2014 at 14:26 Prakash RamanPrakash Raman 6091 gold badge8 silver badges18 bronze badges 3
  • I'm not sure why the japi config is being ignored, however you can follow some tips here and take a look at this article. – phatskat Commented Jan 26, 2018 at 16:13
  • 1 What is this file? If you're handling API requets in WordPress you should use the REST API or AJAX hooks. – Jacob Peattie Commented Mar 22, 2018 at 2:34
  • 1 How do you know it is being neglected? The sample looks exactly like the standard web.config for WordPress and if that's the case, the behavior will be exactly the same as the one in the project root. Can you please rephrase the question as Given x When y I Expect z But Instead See ___? – Ted Stresen-Reuter Commented Apr 14, 2019 at 3:15
Add a comment  | 

1 Answer 1

Reset to default 1

I believe WP uses rewrites and routing through the website's main index.php file (web.config, .htaccess). So, if you don't specify a specific file that you are accessing (i.e. mysite.com/subdir/test.php), then you aren't really playing in that sub-directory, your just following the core rewrite rules.

So - if you create a file called test.php inside of a directory called subdir, and you access it directly (as in mysite.com/subdir/test.php) then you should expect the proper web.config should be used; however, since you are not accessing a specific file directly, you are using the folder-structure/endpoint, which uses WP's routing functionality. This may be the reason that the web.config file is being ignored and may be the answer to your question.

本文标签: url rewritingwebconfig conflict on IIS