我需要知道如何在同一个.htaccess文件中创建以下规则:
example.com/st
重定向到example.com
example.com/[ANY STRING]
重定向到new-example.com/[ANY STRING]
问题是我需要按原样发送查询字符串。
答案 0 :(得分:0)
您的问题不是很明确,但您可以在.htaccess文件中尝试此代码:
Options +FollowSymLinks -MultiViews
RewriteEngine on
# your first requirement
RewriteRule ^st/?$ / [L]
# your second requirement; it will also append existing query string
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^ http://new-example.com%{REQUEST_URI} [L,R=301]