如何使用.htaccess 301将Feed网址重定向到主页

时间:2016-07-18 07:09:03

标签: php .htaccess mod-rewrite joomla rss

我想通过此链接进行301永久重定向

http://www.example.com/media-center/gum-guru-blog.feed?type=rss

http://www.example.com/。我在.httaccess文件中写了以下几行,但它不起作用。

RewriteRule /media-center/gum-guru-blog.feed?type=rss / [L,R=301]
redirect 301 /media-center/gum-guru-blog.feed?type=rss http://www.example.com 

1 个答案:

答案 0 :(得分:0)

如果您有查询字符串?type=rss,则无法使用RewriteCond %{QUERY_STRING} ^type=rss$ [NC] RewriteCond %{REQUEST_URI} ^\/media-center\/gum-guru-blog\.feed$ [NC] RewriteRule ^(.*)$ /? [R=301,L] 您必须使用包含此查询字符串的重写条件的重写规则:

    VOWELS = 'aeiou' 

    #stores the amount of vowels and consonants according to the parameters above
    vowcount = 0
    concount = 0

    vowcollected_str = ''
    concollected_str = ''

    last_vowel_index = 0

    #ends the program once 5 vowels or consonants have been stored
    while vowcount < 5 and concount < 5: 
        word = input('Input a word: ')
        wordlow = word.lower()

        for i, ch in enumerate(wordlow):
            if ch in VOWELS:
                last_vowel_index = i
                if ch not in vowcollected_str:
                    vowcollected_str += ch 
                    vowcount += 1
                    if ch not in VOWELS:
                        if wordlow[i+1:] not in concollected_str:
                            concollected_str += (wordlow[i+1:])
                            concount += 1

    print("\n"+"="*12)
    print("{:8s}{:7s} | {:12s}{:7s}".format("vowels","length","consonants","length"))         
    print("{:<8s}{:<7d} | {:<12s}{:<6d}".format(vowcollected_str,vowcount,concollected_str,concount))

如果需要,使用[NC]标志不区分大小写。