【问题标题】:What is the Apache URL Rewrite rule for my .htaccess file for this IIS rule?对于此 IIS 规则,我的 .htaccess 文件的 Apache URL 重写规则是什么?
【发布时间】:2014-01-06 02:27:26
【问题描述】:

这是 IIS 规则:

            <rule name="Pin">
                <match url="^pin/([^]+)/" />
                <action type="Rewrite" url="pin.php?id={R:1}" />
            </rule>

这在 Apache 的 .htaccess 文件中会是什么样子?

【问题讨论】:

    标签: apache .htaccess iis mod-rewrite url-rewriting


    【解决方案1】:
    RewriteRule ^pin/([^]+)/ pin.php?id=$1 [L]
    

    现在这对你来说真的很容易。 &lt;match url=""&gt; 值进入规则的第一个参数,&lt;action&gt; 的 url 值进入规则的第二个参数,将任何 {R:#} 替换为 $#,并在必要时结束。

    【讨论】:

    • 我在使用该重写规则时收到此错误。任何想法为什么我会得到这个? Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at webmaster@disneypinplace.com to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
    • @EthanAllen 听起来你已经打开了Multiviews,你需要在你的htaccess文件的某个地方添加Options -Multiviews。要么,要么这个规则与你的 htaccess 文件中的其他内容冲突。
    【解决方案2】:

    我相信这是导致500 的相同正则表达式问题,这应该可以工作:

    RewriteEngine On
    
    RewriteRule ^pin/([^/]+)/$ /pin.php?id=$1 [L,QSA,NC]
    

    【讨论】:

      猜你喜欢
      • 2012-08-22
      • 1970-01-01
      • 2014-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多