如何在.htaccess中制作多个永久链接?

时间:2015-07-06 12:38:35

标签: regex apache .htaccess mod-rewrite permalinks

问题是我有一个.htaccess文件重定向用户,转到example.com/f89sk3 - > example.com/?s=f89sk3如果有意义的话。

我希望对于那些去过的人也会发生同样的事情: example.com/p/login - > example.com/p/login

这是我当前的.htaccess文件:

RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.*)$ index.php?s=$1 [QSA,L]

1 个答案:

答案 0 :(得分:1)

您可以使用以下规则:

int anagrams(char * word, char * text) {
    int bin[256] = { 0 }, m = 0, found = 0, len = 0, c, i;
    for (i = 0; word[i]; i++, bin[c]--, len++) {
        c = word[i];
        if(bin[c] == 0) m++;
    }
    for (i = 0; text[i]; i++) {
        c = text[i];
        if (bin[c] == 0) m++;
        if (bin[c] == -1) m--;
        bin[c]++;
        if (i >= len) {
            c = text[i - len];
            if (bin[c] == 0) m++;
            if (bin[c] == 1) m--;
            bin[c]--;
        }
        if (m == 0) found++;
    }
    return found;
}