Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex .htaccess域重定向-TLD agnositc_Regex_.htaccess_Mod Rewrite - Fatal编程技术网

Regex .htaccess域重定向-TLD agnositc

Regex .htaccess域重定向-TLD agnositc,regex,.htaccess,mod-rewrite,Regex,.htaccess,Mod Rewrite,我想将short.tld重定向到longer.tld,而不管tld是dev还是com,也不管请求什么 所以像这样 short.dev should redirect to longer.dev short.com should redirect to longer.com 到目前为止,我有一个正在工作的(for.dev): 。。。但是如何使重写规则中的.dev不可知于TLD?您可以使用类似的方法使其不可知于TLD的部分: RewriteCond %{HTTP_HOST} ^(?:www\.)?

我想将short.tld重定向到longer.tld,而不管tld是dev还是com,也不管请求什么

所以像这样

short.dev should redirect to longer.dev
short.com should redirect to longer.com
到目前为止,我有一个正在工作的(for.dev):


。。。但是如何使重写规则中的.dev不可知于TLD?

您可以使用类似的方法使其不可知于TLD的部分

RewriteCond %{HTTP_HOST} ^(?:www\.)?short\.(.+)$ [NC]
RewriteRule ^ http://longer.%1%{REQUEST_URI} [R=301,L]

意识到问题并修复。请检查编辑的代码。
RewriteCond %{HTTP_HOST} ^(?:www\.)?short\.(.+)$ [NC]
RewriteRule ^ http://longer.%1%{REQUEST_URI} [R=301,L]