我想在htaccess中为这样的网址创建一个重定向:
https://example.com/firstnamelastname?mv=0或https://example.com/firstnamelastname?mv=2
以及https://example.com/firstnamelastname
重定向到https://firstnamelastname.example.com
其中firstnamelastname只能是a-z和0-9。 mv = 0到4。
答案 0 :(得分:0)
如果您只需要重定向,那么您可以使用mod_rewrite:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{QUERY_STRING} ^mv=[0-4]$
RewriteRule ^([A-Za-z0-9]+)$ https://$1.example.com/? [L,R]