Different Default Document Type in Subfolder on IIS 6
I've never worked on an IIS server with PHP before, but my question is can I set a default document type for a subfolder in the web.config, this is what I have in mind (its a bbPress forum):
<location path="forum">
<system.webServer>
<defaultDocument>
<files>
<add val开发者_StackOverflow中文版ue="index.php" />
</files>
</defaultDocument>
</system.webServer>
</location>
Thanks and a virtual beer to the person who answers :D
If you're using IIS7, the configuration you suggest will indeed change the default document for just the subfolder forum
to index.php
.
If this is IIS 6 then it won't work for a non-administrative user. IIS 6 stores these settings in the metabase and can only be edited using:
- IIS Management Console
- Programmatically, but the modifying application requires Administrator rights
- Direct metabase editing
The <system.webServer>
xml web.config
settings are only applicable to IIS 7 and above, IIS 6 will completely ignore these.
I'm not sure if this will work, but if you know what the default document is for your site, you could try to override it with a UrlMapping. For example:
<system.web>
<urlMappings>
<add url="~/forum/Default.aspx" mappedUrl="~/forum/index.php" />
</urlMappings>
</system.web>
Let me know if that works for you. You might have to create a dummy Default.aspx that's simply blank in that directory for it to work.
EDIT: Also, for what it's worth, you can simply just add "index.php" to the list of Default Documents for your whole site. I'm not sure if you knew that. Just put it at the bottom of the list and it won't break any other sections of your site.
精彩评论