开发者

redirecting /directory/ to www.example.com

I'm attempting to redirect /fourm/ on my website back to http://www.example开发者_如何学Go.com

I've come up with this:

RewriteEngine On RewriteRule /forum/(.*) http://www.path.com(.*) [R=301,L]

However it doesn't work, any thoughts appreciated


Almost there you just need to back reference the part of the request you captured like so:

RewriteEngine On
RewriteRule forum/(.*) http://www.path.com/$1 [R=301,L]

$X will reference a captured string in the matching part of the rewrite rule and output its value into the output string. Obviously, with the number corresponding to the group that was captured.


Try it with RedirectMatch

RedirectMatch 301 ^/forum/(.*)$ http://path.com/$1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜