Ste*_*eph 7 apache iis .htaccess webserver web-config
我使用PHP,MySQL和Apache在我的本地开发了一个应用程序,它有一个包含以下内容的.htaccess文件:
#Setting the default handler.
DirectoryIndex home.do
<IfModule mod_mime.c>
#Supporting .do extensions
AddType application/x-httpd-php .do
</IfModule>
<IfModule mod_rewrite.c>
#Removing .do file extension if necessary
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.do -f
RewriteRule ^(.*)$ $1.do
</IfModule>
Run Code Online (Sandbox Code Playgroud)
但我告知我的客户的Web服务器是IIS,我必须使用web.config文件而不是.htaccess.有人可以指导我通过这个吗?
请注意,这仅适用于 IIS7,不适用于 IIS6。此外,这还需要设置 FastCGI并安装并启用URL 重写模块。您的托管服务商可以为您验证这些内容。如果上述所有内容均为真,那么以下文件应该可以解决问题(您可能需要调整路径,但我认为如果您向托管商提供此示例文件,他们将能够为您执行此操作。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<sectionGroup name="system.webServer">
<sectionGroup name="rewrite">
<section name="rewriteMaps" overrideModeDefault="Allow" />
<section name="rules" overrideModeDefault="Allow" />
</sectionGroup>
</sectionGroup>
</configSections>
<system.webServer>
<!-- Mapping the .do extension to the PHP ISAPI module -->
<handlers>
<!-- the following line is very specific to your host
please check the module name and the scriptProcessor
path with the system administrator! basically this is
the same as
http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-70/#EnableFastCGI
only in .config format. -->
<add name="MaskDoAsPHP" path=".do" verb="GET,HEAD,POST,DEBUG" modules="FastCgiModule" scriptProcessor="C:\PHP\php-cgi.exe" />
</handlers>
<!-- Setting the default handler. -->
<defaultDocument>
<files>
<clear />
<add value="home.do" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Removing do extension" 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="{R1}.do" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13888 次 |
| 最近记录: |