.htaccess重定向重写规则

时间:2016-02-25 09:57:06

标签: .htaccess redirect mod-rewrite

我在重新设计网站时遇到了一些重定向问题。 旧的有这样的网址:

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Delegate,Inherited = false)]
[ComVisible(true)]
public class Zasob : Attribute
{
    public Towar Towar { get; set; }
    public Magazyn Magazyn { get; set; }
    public Lokalizacja Lokalizacja { get; set; }
    public decimal Ilosc { get; set; }
}

我想将其重定向到:

http://www.example.com/sitegroup/pages/GA/GA_Be.shtml

我尝试了以下重写:

http://www.example.com/sitegroup/garten-und-landschaftsbau/#gartenforum-ideengarten

但是我无法让它发挥作用..我是.htaccess rewriterules的新手。

还有一些旧页面得到了这样的链接:

RewriteRule ^/?pagesGA/GA_Be.shtml$ http://www.example.com/sitegroup/garten-und-landschaftsbau/#gartenforum-ideengarten$1 [R=301,L,NE]

但是?navid = 15没有做任何事情(只是突出了menulink)所以我认为重新定向GA_BE.shtml就足够了。我是对的吗?

这是完整的.htaccess:

http://www.example.com/sitegroup/pages/GA/GA_Be.shtml?navid=15

提前致谢!

1 个答案:

答案 0 :(得分:2)

您应该在Wordpress Dispatcher之前放置<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Words</title> <link rel="stylesheet" href="style.css" media="screen" title="no title" charset="utf-8"> <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> </head> <body> <header> <a href=""><span class="fa fa-refresh spin" style="font-size:25px;"></span><span class="igen spin">&nbsp;igen</span></a> <span class="points"><i class="fa fa-thumbs-o-up" style="font-size:24px"></i>Rigtige: &nbsp;&nbsp;&nbsp; <span id="rigtige">0</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <i class="fa fa-thumbs-o-down" style="font-size:24px"></i>Forkerte: &nbsp;&nbsp;&nbsp; <span id="forkerte">0</span> </span> </header> <div class="container"> <div class="img" id="img1"> <div class="plaatje" id="plaatje1"> <img class="center" src="img/cat.jpg" alt="cat" width="50%;"> </div> <div class="move1"> <div class="antwoord droppable" id="antwoord1"><i class="fa fa-play" style="font-size:20px"></i> </div> </div> </div> <div class="img" id="img2"> <div class="plaatje" id="plaatje1"> <img class="center" src="img/beak.jpg" alt="beak" width="50%;"> </div> <div class="move2"> <div class="antwoord" id="antwoord2"><i class="fa fa-play" style="font-size:20px"></i> </div> </div> </div> <div class="img" id="img3"> <div class="plaatje" id="plaatje3"> <img class="center" src="img/spoon.jpg" alt="spoon" width="50%;"> </div> <div class="move3"> <div class="antwoord" id="antwoord3"><i class="fa fa-play" style="font-size:20px"></i> </div> </div> </div> <div class="img" id="img4"> <div class="plaatje" id="plaatje4"> <img class="center" src="img/milk.jpg" alt="milk" width="50%;"> </div> <div class="move4"> <div class="antwoord" id="antwoord4"><i class="fa fa-play" style="font-size:20px"></i> </div> </div> </div> <div class="img" id="img5"> <div class="plaatje" id="plaatje5"> <img class="center" src="img/egg.jpg" alt="egg" width="50%;"> </div> <div class="move5"> <div class="antwoord" id="antwoord5"><i class="fa fa-play" style="font-size:20px"></i> </div> </div> </div> <div class="img" id="img6"> <div class="plaatje" id="plaatje6"> <img class="center" src="img/thee.jpg" alt="tea" width="50%;"> </div> <div class="move6"> <div class="antwoord" id="antwoord6"><i class="fa fa-play" style="font-size:20px"></i> </div> </div> </div> <div class="img" id="img7"> <div class="plaatje" id="plaatje7"> <img class="center" src="img/meel.jpg" alt="flour" width="50%;"> </div> <div class="move7"> <div class="antwoord" id="antwoord7"><i class="fa fa-play" style="font-size:20px"></i> </div> </div> </div> <div class="img" id="img8"> <div class="plaatje" id="plaatje8"> <img class="center" src="img/passport.jpg" alt="passport" width="50%;"> </div> <div class="move8"> <div class="antwoord" id="antwoord8"><i class="fa fa-play" style="font-size:20px"></i> </div> </div> </div> <div class="answers"> <div class="my-row border"> <div class="word" id="word0"></div> <div class="word" id="word1"></div> <div class="word" id="word2"></div> <div class="word" id="word3"></div> </div> <div class="my-row"> <div class="word2" id="word4"></div> <div class="word2" id="word5"></div> <div class="word2" id="word6"></div> <div class="word2" id="word7"></div> </div> </div> <footer> <img class="dansk" id="dansk" src="img/dansk2.jpg" alt="dansk" /> <img class="sprint" id="sprint" src="img/sprint2.png" alt="sprint" /> <center><span class="copyright"> &copy;2013 laerdansk / FC-Sprint&sup2; Leerbedrijf bronnen </span> </center> </footer> <script type="text/javascript"> var jsonData = "noJson"; var hr = new XMLHttpRequest(); hr.open("GET", "json_files/jsonData_0_123.json", true); hr.setRequestHeader("Content-type", "application/json", true); hr.onreadystatechange = function() { if (hr.readyState == 4 && hr.status == 200) { jsonData = JSON.parse(hr.responseText).main_object; } } hr.send(null); </script> <script src="javascript.js"></script> </body> </html>

RewriteRule

否则,请求将首先由Dispatcher处理,永远不会达到您的规则。