同时重定向到新域以及结构

时间:2016-06-08 09:07:01

标签: .htaccess redirect

只是有一个问题将域重定向到另一个域以及同时更改URL的结构。我正在使用.htaccess使用ISASPI。

我有2个网址,我想更改以下内容:

http://www.example.co.uk/something-jobs/test-article-name/12345678

http://www.examplenew.co.uk/news/test-article-name/

我目前的规则如下:

RewriteRule ^Something-Jobs/.*/ http://www.examplenew.co.uk/news/([^/]+)(?=/[^/]+/?$) [R=301,L]

当然哪个错了。你有机会告诉我哪里出错了吗?

非常感谢任何帮助!

1 个答案:

答案 0 :(得分:1)

是的,这是错的。你不能在RewriteTarget中使用正则表达式。像这样修改你的规则:

RewriteRule ^Something-Jobs/([^/]+)/[0-9]+$ http://www.examplenew.co.uk/news/$1 [NC,R=301,L]

您也可以使用RedirectMatch指令

RedirectMatch 301 ^/Something-Jobs/([^/]+)/[0-9]+$ http://www.examplenew.co.uk/news/$1