我正在將我的Web應用程序從Apache 2.4.17遷移到Microsoft-IIS/7.5。在我的應用程序的根目錄中是需要轉換爲Web.config的.htaccess文件。將.htaccess文件融合到Web.config中
經過多次嘗試,我無法做到成功的轉換。 Microsoft-IIS不斷返回404 - 找不到文件錯誤。我沒有編寫Web.config文件的經驗,所以任何來自更有經驗的眼睛的幫助將不勝感激。
這裏是工作的罰款在Apache .htaccess文件:
php_value post_max_size 70M
RewriteEngine on
# In case router is called do nothing
RewriteRule ^framework/Router.php(.)*$ - [L]
# Prevents user from making a request to a specific .php file
RewriteRule ^[A-Za-z/]+.php$ - [F,L]
# Application index page
RewriteRule ^$ domov [L]
# Redirect everything else to Router.php
RewriteRule ^[A-Za-z/]+$ framework/Router.php [L]
RewriteRule ^([A-Za-z/]+)([0-9]+)$ framework/Router.php?id=$2 [L]
RewriteRule ^([A-Za-z/]+)/(page=[0-9]+)$ framework/Router.php?$2 [L]
這裏是我寫上的Web.config文件的嘗試:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rule 1G" stopProcessing="true">
<match url="^framework/Router.php(.)*$"/>
<action type="Rewrite" url="/-" />
</rule>
<rule name="rule 2G" stopProcessing="true">
<match url="^[A-Za-z/]+.php$" />
<action type="Rewrite" url="/-"/>
</rule>
<rule name="rule 3G" stopProcessing="true">
<match url="^$" />
<action type="Rewrite" url="/domov"/>
</rule>
<rule name="rule 4G" stopProcessing="true">
<match url="^[A-Za-z/]+$" />
<action type="Rewrite" url="/framework/Router.php"/>
</rule>
<rule name="rule 5G" stopProcessing="true">
<match url="^([A-Za-z/]+)([0-9]+)$" />
<action type="Rewrite" url="/framework/Router.php?id={R:2}" appendQueryString="true" />
</rule>
<rule name="rule 6G" stopProcessing="true">
<match url="^([A-Za-z/]+)/(page=[0-9]+)$" />
<action type="Rewrite" url="/framework/Router.php?{R:2}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
謝謝你,我遵循你的答案,現在它的工作正常。正如一個側面說明,如果你沒有安裝IIS管理器,它會在這個問題中介紹:http://stackoverflow.com/questions/30901434/iis-manager-in-windows-10 – hardidoo