Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess htaccess重写404错误_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess htaccess重写404错误

.htaccess htaccess重写404错误,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有一个旧的wordpress博客,我需要将所有帖子重定向到一个新系统,但url略有不同,帖子的日期被删除。例如,旧url如下所示: http://www.myolddomain.com/2012/11/30/the-title-of-my-post/ http://www.mynewdomain.com/blog/2012/11/the-title-of-my-post 但新的url如下所示: http://www.myolddomain.com/2012/11/30/the-title-

我有一个旧的wordpress博客,我需要将所有帖子重定向到一个新系统,但url略有不同,帖子的日期被删除。例如,旧url如下所示:

http://www.myolddomain.com/2012/11/30/the-title-of-my-post/
http://www.mynewdomain.com/blog/2012/11/the-title-of-my-post
但新的url如下所示:

http://www.myolddomain.com/2012/11/30/the-title-of-my-post/
http://www.mynewdomain.com/blog/2012/11/the-title-of-my-post
我花了很长时间才把它重写好。我一直收到这样一条消息:在旧服务器上找不到url(404)。所以它不是重定向。以下是我当前的htaccess条目:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^/([0-9]+)$/([0-9]+)$/([0-9]+)$/([0-9]+)$ http://www.mynewdomain.com/blog/$1/$2/$4[R=301,L]
非常感谢您的建议。

请尝试:

RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/([a-z0-9\-]+)/$ http://www.mynewdomain.com/blog/$1/$2/$4 [R=301,L]
$
符号(即
end
)应仅附加在末尾(如有必要!)


经过测试,效果良好。

谢谢!成功了!我知道一定是一些我看不见的简单的东西。