将规则 .htaccess 重写为 web.config
rewrite rule .htaccess to web.config
目前我在 运行 网站上使用简单的 linux 托管,但我购买了 windows VPS,我在其中安装了 2008 服务器 + plesk,我正在尝试移动新网站 VPS。
我遇到了一个问题 - 第一个 index.php 页面看起来不错,但它只是登录页面,所以我必须输入 login/password 凭据,成功登录后我应该在管理员面板中,但有一个错误:
"500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
"
我认为我必须将我的 .httaccess 文件转换为 web.config,但我仍然收到该错误。不知道是我做错了还是必须做点别的。
这是.httaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{REQUEST_FILENAME} !-f
#module@account
RewriteRule ^login.html$ /index.php?m=login [L]
RewriteRule ^wyloguj.html$ /index.php?m=login&a=wyloguj [L]
#RewriteRule ^nowehaslo,(.*).html$ /index.php?m=login&a=nowehaslo&token= [L]
#module@panel,ajax
RewriteRule ^panel.html$ /index.php?m=panel [L]
RewriteRule ^panel,ajax.html$ /index.php?m=panel&a=ajax [L]
RewriteRule ^produkt/([0-9]*)/(.*)$ /index.php?m=panel&a=produktplik&user=&file= [L]
RewriteRule ^faktura/(.*).pdf$ /index.php?m=panel&a=faktura&crypt= [L]
RewriteRule ^productcount,([a-z]*),([0-9]*),([0-9]*).(.*)$ /index.php?m=panel&a=productcount&type=&user=&product= [L]
RewriteRule ^sprawdz.html$ /index.php?m=panel&a=sprawdz [L]
#module@claim
RewriteRule ^reklamacja,(.*).html$ /index.php?m=claim&ident= [L]
#module@cron
RewriteRule ^cron,([a-zA-Z0-9_]*).html$ /index.php?m=cron&f= [L]
RewriteRule ^userCron,(.*),(.*).html$ /index.php?m=cron&a=userCron&f=&user= [L]
这里web.config
<?xmlversion="1.0"encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rulename="rule1e"stopProcessing="true">
<matchurl="^login.html$"/>
<actiontype="Rewrite"url="//index.php?m=login"/>
</rule>
<rulename="rule2e"stopProcessing="true">
<matchurl="^wyloguj.html$"/>
<actiontype="Rewrite"url="//index.php?m=login&a=wyloguj"/>
</rule>
<rulename="rule3e"stopProcessing="true">
<matchurl="^panel.html$"/>
<actiontype="Rewrite"url="//index.php?m=panel"/>
</rule>
<rulename="rule4e"stopProcessing="true">
<matchurl="^panel,ajax.html$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=ajax"/>
</rule>
<rulename="rule5e"stopProcessing="true">
<matchurl="^produkt/([0-9]*)/(.*)$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=produktplik&user={R:1}&file={R:2}"/>
</rule>
<rulename="rule6e"stopProcessing="true">
<matchurl="^faktura/(.*).pdf$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=faktura&crypt={R:1}"/>
</rule>
<rulename="rule7e"stopProcessing="true">
<matchurl="^productcount,([a-z]*),([0-9]*),([0-9]*).(.*)$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=productcount&type={R:1}&user={R:2}&product={R:3}"/>
</rule>
<rulename="rule8e"stopProcessing="true">
<matchurl="^sprawdz.html$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=sprawdz"/>
</rule>
<rulename="rule9e"stopProcessing="true">
<matchurl="^reklamacja,(.*).html$"/>
<actiontype="Rewrite"url="//index.php?m=claim&ident={R:1}"/>
</rule>
<rulename="rule10e"stopProcessing="true">
<matchurl="^cron,([a-zA-Z0-9_]*).html$"/>
<actiontype="Rewrite"url="//index.php?m=cron&f={R:1}"/>
</rule>
<rulename="rule11e"stopProcessing="true">
<matchurl="^userCron,(.*),(.*).html$"/>
<actiontype="Rewrite"url="//index.php?m=cron&a=userCron&f={R:1}&user={R:2}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
有人可以帮我吗?
干杯
重写规则不太可能导致 500 错误。所以,首先,我建议您尝试直接请求目的地,绕过规则,看看它是否能以这种方式工作。
您还可以启用登录 ISAPI_Rewrite 以查看问题是否由于重写而发生。
最后,您可以使用 IIS 中的失败请求跟踪工具来查看请求发生的所有情况,查看它在哪个阶段失败,"who" 负责这个阶段。
目前我在 运行 网站上使用简单的 linux 托管,但我购买了 windows VPS,我在其中安装了 2008 服务器 + plesk,我正在尝试移动新网站 VPS。 我遇到了一个问题 - 第一个 index.php 页面看起来不错,但它只是登录页面,所以我必须输入 login/password 凭据,成功登录后我应该在管理员面板中,但有一个错误:
"500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
"
我认为我必须将我的 .httaccess 文件转换为 web.config,但我仍然收到该错误。不知道是我做错了还是必须做点别的。
这是.httaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{REQUEST_FILENAME} !-f
#module@account
RewriteRule ^login.html$ /index.php?m=login [L]
RewriteRule ^wyloguj.html$ /index.php?m=login&a=wyloguj [L]
#RewriteRule ^nowehaslo,(.*).html$ /index.php?m=login&a=nowehaslo&token= [L]
#module@panel,ajax
RewriteRule ^panel.html$ /index.php?m=panel [L]
RewriteRule ^panel,ajax.html$ /index.php?m=panel&a=ajax [L]
RewriteRule ^produkt/([0-9]*)/(.*)$ /index.php?m=panel&a=produktplik&user=&file= [L]
RewriteRule ^faktura/(.*).pdf$ /index.php?m=panel&a=faktura&crypt= [L]
RewriteRule ^productcount,([a-z]*),([0-9]*),([0-9]*).(.*)$ /index.php?m=panel&a=productcount&type=&user=&product= [L]
RewriteRule ^sprawdz.html$ /index.php?m=panel&a=sprawdz [L]
#module@claim
RewriteRule ^reklamacja,(.*).html$ /index.php?m=claim&ident= [L]
#module@cron
RewriteRule ^cron,([a-zA-Z0-9_]*).html$ /index.php?m=cron&f= [L]
RewriteRule ^userCron,(.*),(.*).html$ /index.php?m=cron&a=userCron&f=&user= [L]
这里web.config
<?xmlversion="1.0"encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rulename="rule1e"stopProcessing="true">
<matchurl="^login.html$"/>
<actiontype="Rewrite"url="//index.php?m=login"/>
</rule>
<rulename="rule2e"stopProcessing="true">
<matchurl="^wyloguj.html$"/>
<actiontype="Rewrite"url="//index.php?m=login&a=wyloguj"/>
</rule>
<rulename="rule3e"stopProcessing="true">
<matchurl="^panel.html$"/>
<actiontype="Rewrite"url="//index.php?m=panel"/>
</rule>
<rulename="rule4e"stopProcessing="true">
<matchurl="^panel,ajax.html$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=ajax"/>
</rule>
<rulename="rule5e"stopProcessing="true">
<matchurl="^produkt/([0-9]*)/(.*)$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=produktplik&user={R:1}&file={R:2}"/>
</rule>
<rulename="rule6e"stopProcessing="true">
<matchurl="^faktura/(.*).pdf$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=faktura&crypt={R:1}"/>
</rule>
<rulename="rule7e"stopProcessing="true">
<matchurl="^productcount,([a-z]*),([0-9]*),([0-9]*).(.*)$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=productcount&type={R:1}&user={R:2}&product={R:3}"/>
</rule>
<rulename="rule8e"stopProcessing="true">
<matchurl="^sprawdz.html$"/>
<actiontype="Rewrite"url="//index.php?m=panel&a=sprawdz"/>
</rule>
<rulename="rule9e"stopProcessing="true">
<matchurl="^reklamacja,(.*).html$"/>
<actiontype="Rewrite"url="//index.php?m=claim&ident={R:1}"/>
</rule>
<rulename="rule10e"stopProcessing="true">
<matchurl="^cron,([a-zA-Z0-9_]*).html$"/>
<actiontype="Rewrite"url="//index.php?m=cron&f={R:1}"/>
</rule>
<rulename="rule11e"stopProcessing="true">
<matchurl="^userCron,(.*),(.*).html$"/>
<actiontype="Rewrite"url="//index.php?m=cron&a=userCron&f={R:1}&user={R:2}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
有人可以帮我吗?
干杯
重写规则不太可能导致 500 错误。所以,首先,我建议您尝试直接请求目的地,绕过规则,看看它是否能以这种方式工作。 您还可以启用登录 ISAPI_Rewrite 以查看问题是否由于重写而发生。 最后,您可以使用 IIS 中的失败请求跟踪工具来查看请求发生的所有情况,查看它在哪个阶段失败,"who" 负责这个阶段。