0

I've been staring at this for far too long. To cope with a Wordpress URL structure change, I need a URL rewrite to cope with old links that are floating around the net. The rule I've created is

RewriteRule [0-9]+/[0-9]+/[0-9]+/(.+)$ /$1 [R=301,L]

To match posts with URLs like

/2013/02/05/Some-wonderful-article 

supposedly redirecting to

/Some-wonderful-article

Apache seems to be ignoring this, though, and happily sticks with the original URL. Can anyone see why? Am I forgetting some quirk of Apache's implementation of regex? I've already wasted some time playing with \d instead of [0-9] ...

4

1 回答 1

0

试试这个规则:

RewriteEngine on
RewriteBase /
RewriteRule ^/?[0-9]+/[0-9]+/[0-9]+/(.+)$ /$1 [R=301,L]

我添加了激活重写引擎的命令以及定义 RewriteRules 基础的行。

于 2013-02-05T17:36:42.900 回答