【问题标题】:rewrite rule .htaccess to web.config将规则 .htaccess 重写为 web.config
【发布时间】:2015-02-03 21:33:01
【问题描述】:

目前我在简单的 linux 主机上运行站点,但我购买了安装 2008 server + plesk 的 windows VPS,我正试图将站点移到新的 VPS 上。 我遇到了一个问题 - 第一个 index.php 页面看起来不错,但它只是登录页面,所以我必须输入登录/密码凭据,成功登录后我应该在管理员面板中,但出现错误:

"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=$1             [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=$1&file=$2    [L]
RewriteRule ^faktura/(.*).pdf$                                  /index.php?m=panel&a=faktura&crypt=$1               [L]
RewriteRule ^productcount,([a-z]*),([0-9]*),([0-9]*).(.*)$      /index.php?m=panel&a=productcount&type=$1&user=$2&product=$3    [L]
RewriteRule ^sprawdz.html$                                      /index.php?m=panel&a=sprawdz                        [L]

#module@claim
RewriteRule ^reklamacja,(.*).html$                              /index.php?m=claim&ident=$1                         [L]

#module@cron
RewriteRule ^cron,([a-zA-Z0-9_]*).html$                         /index.php?m=cron&f=$1                              [L]
RewriteRule ^userCron,(.*),(.*).html$                           /index.php?m=cron&a=userCron&f=$1&user=$2           [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&amp;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&amp;a=ajax"/>
</rule>

<rulename="rule5e"stopProcessing="true">
	<matchurl="^produkt/([0-9]*)/(.*)$"/>
	<actiontype="Rewrite"url="//index.php?m=panel&amp;a=produktplik&amp;user={R:1}&amp;file={R:2}"/>
</rule>

<rulename="rule6e"stopProcessing="true">
	<matchurl="^faktura/(.*).pdf$"/>
	<actiontype="Rewrite"url="//index.php?m=panel&amp;a=faktura&amp;crypt={R:1}"/>
</rule>

<rulename="rule7e"stopProcessing="true">
	<matchurl="^productcount,([a-z]*),([0-9]*),([0-9]*).(.*)$"/>
	<actiontype="Rewrite"url="//index.php?m=panel&amp;a=productcount&amp;type={R:1}&amp;user={R:2}&amp;product={R:3}"/>
</rule>

<rulename="rule8e"stopProcessing="true">
	<matchurl="^sprawdz.html$"/>
	<actiontype="Rewrite"url="//index.php?m=panel&amp;a=sprawdz"/>
</rule>

<rulename="rule9e"stopProcessing="true">
	<matchurl="^reklamacja,(.*).html$"/>
	<actiontype="Rewrite"url="//index.php?m=claim&amp;ident={R:1}"/>
</rule>

<rulename="rule10e"stopProcessing="true">
	<matchurl="^cron,([a-zA-Z0-9_]*).html$"/>
	<actiontype="Rewrite"url="//index.php?m=cron&amp;f={R:1}"/>
</rule>

<rulename="rule11e"stopProcessing="true">
	<matchurl="^userCron,(.*),(.*).html$"/>
	<actiontype="Rewrite"url="//index.php?m=cron&amp;a=userCron&amp;f={R:1}&amp;user={R:2}"/>
</rule>

</rules>
</rewrite>
</system.webServer>
</configuration>

有人可以帮我吗?

干杯

【问题讨论】:

    标签: web-config url-rewrite-module isapi-rewrite


    【解决方案1】:

    RewriteRule 极不可能导致 500 错误。所以,首先,我建议你尝试直接请求目的地,绕过规则,看看它是否可以这样工作。 您还可以在 ISAPI_Rewrite 中启用日志记录,以查看问题是否由于重写而发生。 最后,您可以使用 IIS 中的失败请求跟踪工具来查看请求发生的所有事情,查看它在哪个阶段失败以及“谁”负责这个阶段。

    【讨论】:

      猜你喜欢
      • 2012-08-22
      • 1970-01-01
      • 2013-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-30
      • 2016-08-09
      • 1970-01-01
      相关资源
      最近更新 更多