在@anubhava的帮助下,我有了这个不错的RewriteRule。
short.dev redirects to longer.dev
short.com redirects to longer.com
使用这个:
RewriteCond %{HTTP_HOST} ^(?:www\.)?short\.(.+)$ [NC]
RewriteRule ^ http://longer.%1%{REQUEST_URI} [R=301,L]
我现在需要扩展此规则,使其也与子域无关-像这样:
www.short.dev redirects to www.longer.dev
www.short.com redirects to www.longer.com
es.short.dev redirects to es.longer.dev
es.short.com redirects to es.longer.com
您可以将第一个组设为捕获的组,并在以后的反向引用中使用它:
RewriteCond %{HTTP_HOST} ^(www\.)?short\.(.+)$ [NC]
RewriteRule ^ http://%1longer.%2%{REQUEST_URI} [R=301,L,NE]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句