.htaccess 使用htaccess重定向域的正确语法是什么?

.htaccess 使用htaccess重定向域的正确语法是什么?,.htaccess,.htaccess,没有$美元符号 RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^11\.111\.111\.111 [NC,OR] RewriteCond %{HTTP_HOST} ^olddomain.net [NC,OR] RewriteCond %{HTTP_HOST} ^olddomain.org [NC,OR] RewriteCond %{HTTP_HOST} ^newdomain.com [NC] RewriteRule ^(.*)$

没有$美元符号

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^11\.111\.111\.111 [NC,OR]
RewriteCond %{HTTP_HOST} ^olddomain.net [NC,OR]
RewriteCond %{HTTP_HOST} ^olddomain.org [NC,OR]
RewriteCond %{HTTP_HOST} ^newdomain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^11\.111\.111\.111$ [NC,OR]
RewriteCond %{HTTP_HOST} ^olddomain.net$ [NC,OR]
RewriteCond %{HTTP_HOST} ^olddomain.org$ [NC,OR]
RewriteCond %{HTTP_HOST} ^newdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
$美元符号

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^11\.111\.111\.111 [NC,OR]
RewriteCond %{HTTP_HOST} ^olddomain.net [NC,OR]
RewriteCond %{HTTP_HOST} ^olddomain.org [NC,OR]
RewriteCond %{HTTP_HOST} ^newdomain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^11\.111\.111\.111$ [NC,OR]
RewriteCond %{HTTP_HOST} ^olddomain.net$ [NC,OR]
RewriteCond %{HTTP_HOST} ^olddomain.org$ [NC,OR]
RewriteCond %{HTTP_HOST} ^newdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
因此,我想将所有流量重定向到具有相同URL的新域。 例如:

http://olddomain.net/post-123/
http://olddomain.org/post-123/


那么哪一个是正确的呢?带或不带$符号?

正确的版本是带$
因为$正好表示字符串的结尾

与:

您还可以重定向11.111.111.112或113或11999999
最后不是美元。
然而,对于示例的所有值,它不应该改变任何东西

要真正正确,您还必须在点之前添加
\
,否则它可能会被字母或其他符号替换。但再一次,在这种情况下,它不会改变任何事情

RewriteCond %{HTTP_HOST} ^newdomain\.com$ [NC]

这与语法无关,两种形式在语法上都是正确的。这是一个你想要匹配什么的问题,所以是语义的问题。。。