Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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
Regex 如何在htaccess中编写此301规则_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Regex 如何在htaccess中编写此301规则

Regex 如何在htaccess中编写此301规则,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,我已经从一个免费的博客服务转移到我自己的主机。我不能完全控制我的旧博客引擎,但我可以通过主题创建设施重写一些链接。这样,我计划将我的老用户重定向到我的新站点 链接,如http://oldomain.com/post/post_id将被写成http://newdomain.com/http://olddomain.com/post/post_id因为主题化工具不允许我获取相对于站点根目录的URL 我想做的是重定向http://newdomain.com/http://olddomain.com/p

我已经从一个免费的博客服务转移到我自己的主机。我不能完全控制我的旧博客引擎,但我可以通过主题创建设施重写一些链接。这样,我计划将我的老用户重定向到我的新站点

链接,如
http://oldomain.com/post/post_id
将被写成
http://newdomain.com/http://olddomain.com/post/post_id
因为主题化工具不允许我获取相对于站点根目录的URL

我想做的是重定向
http://newdomain.com/http://olddomain.com/post/post_id
http://newdomain.com/post/post_id
在我的新域上使用
.htaccess
文件

如何使用
.htaccess
文件实现此目的?

您可以使用:

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+http://[^/]+([^\s]+) [NC]
RewriteRule ^ %1 [R=301,L,NE]

谢谢,就像一个符咒:)不客气,很高兴这对你有用。当然,我只是在等待冷却期结束。