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
精彩评论