hir*_*hal 7 php .htaccess redirect
83answers.com如果url包含forum字符串,我想重定向到不同的域.
就像我的网址test.guru99.com/forum/xyxyxzz那样它应该重定向到83answers.com.字符串论坛可以在网址的任何位置.
我试过以下
RewriteCond %{QUERY_STRING} forum
RewriteRule .* 83answers.com [R,L]
Run Code Online (Sandbox Code Playgroud)
还有这个
RewriteCond %{REQUEST_URI} forum
RewriteRule .* 83answers.com
Run Code Online (Sandbox Code Playgroud)
但两者都没有用,请帮我解决这个问题.
问候
对于基本URL,您不需要RewriteCond,只需RewriteRule:
RewriteRule forum http://83answers.com [R,L]
Run Code Online (Sandbox Code Playgroud)
对于查询字符串,您几乎就在那里:
RewriteCond %{QUERY_STRING} forum
RewriteRule .? http://83answers.com [R,L]
Run Code Online (Sandbox Code Playgroud)
合并规则:
RewriteRule forum http://83answers.com [R,L]
RewriteCond %{QUERY_STRING} forum
RewriteRule .? http://83answers.com [R,L]
Run Code Online (Sandbox Code Playgroud)
请注意,您必须包括http://.如果您只是使用83answers.com,服务器会尝试重定向到您服务器上的URL.例如,它会重定向http://test.guru99.com/forum/xyxyxzz到http://test.guru99.com/83answers.com,这是不好的.