301重定向到重写的网址

时间:2016-02-02 21:56:40

标签: regex .htaccess redirect mod-rewrite

我正在使用的CMS有这些重写规则:

对于标签:

RewriteRule ^tags/([^/]+)/$ tag.php?t=$1&page=1
RewriteRule ^tags/([^/]+)/page-([0-9]+)(/)?$ tag.php?t=$1&page=$2

用于类别页面:

RewriteRule ^browse-(.*)-videos.html$ category.php?cat=$1
RewriteRule ^browse-(.*)-videos-([0-9]+)-(.*).html$ category.php?cat=$1&page=$2&sortby=$3

但是它没有重定向到seo友好的url estructure创建重复的内容问题,我怎么能这样做,如果从另一个访问,它还重定向到重写的URL?

提前致谢

1 个答案:

答案 0 :(得分:1)

您需要创建4条新规则并将它们置于现有规则之上。

var names = ["riotgames", "example"];
var promises = [];

for (var i = 0; i < names.length; i++) {
    // $.getJSON returns a promise
    promises.push($.getJSON('https://api.twitch.tv/kraken/streams/' + names[i]));
}

// Combine all promises
// and run a callback
$.when.apply($, promises).then(function(){
    var online = [];

    // This callback will be passed the result of each AJAX call as a parameter
    for(var i = 0; i < arguments.length; i++){
        // arguments[i][0] is needed because each argument
        // is an array of 3 elements.
        // The data, the status, and the jqXHR object
        online.push(arguments[i][0].stream.channel.display_name);
    }

    console.log(online);
});