.htaccess重定向博客帖子,但不重定向博客子文件夹

时间:2016-01-29 16:49:44

标签: .htaccess redirect

我需要将旧的博客文件夹重定向到我的新博客文件夹,但保留后标题的名称。

# key is always the same $key = "mysimplekey"; # text is always the same $plaintext = "text_to_encrypt"; $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $ciphertext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $plaintext, MCRYPT_MODE_CBC, $iv); $ciphertext = $iv . $ciphertext; $ciphertext_base64 = base64_encode($ciphertext); $ciphertext_url = rawurlencode($ciphertext_base64); # gives different values for the same key & encryption text: echo $ciphertext_url; $key = 'mysimplekey'; $ciphertext_dec = base64_decode($_REQUEST['u']); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); # retrieves the IV, iv_size should be created using mcrypt_get_iv_size() $iv_dec = substr($ciphertext_dec, 0, $iv_size); # retrieves the cipher text (everything except the $iv_size in the front) $ciphertext_dec = substr($ciphertext_dec, $iv_size); # may remove 00h valued characters from end of plain text $ciphertext_dec = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec));

我写道:

/oldblog/post-title

这一直有效,直到我碰到像/newblog/post-title

这样的网址

我想从此规则中排除RedirectMatch 301 /oldblog/(.*) /newblog/$1 。感谢。

1 个答案:

答案 0 :(得分:0)

要排除oldblog / events,您可以使用:

RedirectMatch 301 ^/oldblog/((?!events).*)$ /newblog/$1

在测试此代码之前清除浏览器的缓存。