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
.htaccess htaccess将子域和子目录重定向到外部url_.htaccess_Redirect_Subdomain_Subdirectory_External Url - Fatal编程技术网

.htaccess htaccess将子域和子目录重定向到外部url

.htaccess htaccess将子域和子目录重定向到外部url,.htaccess,redirect,subdomain,subdirectory,external-url,.htaccess,Redirect,Subdomain,Subdirectory,External Url,我要重定向: http://cbpq.luisgustavoventura.com/ 及 http://luisgustavoventura.com/cbpq/ 致: http://cbpq.org.br/ 我试过: RewriteCond %{HTTP_HOST} ^(cbpq\.luisgustavoventura\.com|luisgustavoventura\.com/cbpq)$ [NC] RewriteRule ^(.*) https://www.cbpq.org.br/$1 [L,

我要重定向:

http://cbpq.luisgustavoventura.com/
http://luisgustavoventura.com/cbpq/

致:

http://cbpq.org.br/

我试过:

RewriteCond %{HTTP_HOST} ^(cbpq\.luisgustavoventura\.com|luisgustavoventura\.com/cbpq)$ [NC]
RewriteRule ^(.*) https://www.cbpq.org.br/$1 [L,R]
但是不起作用


请建议。

您无法使用
%{HTTP\u HOST}
变量匹配
/cbpq
。最好将这些作为两条单独的规则:

RewriteCond %{HTTP_HOST} ^luisgustavoventura\.com$ [NC]
RewriteRule ^cbpq(/.*)?$ http://www.cbpq.org.br$1 [L,NC,R=302]

RewriteCond %{HTTP_HOST} ^cbpq\.luisgustavoventura\.com$ [NC]
RewriteRule ^(.*)$ http://www.cbpq.org.br/$1 [L,NC,R=302]

无法使用
%{HTTP\u HOST}
变量匹配
/cbpq
。最好将这些作为两条单独的规则:

RewriteCond %{HTTP_HOST} ^luisgustavoventura\.com$ [NC]
RewriteRule ^cbpq(/.*)?$ http://www.cbpq.org.br$1 [L,NC,R=302]

RewriteCond %{HTTP_HOST} ^cbpq\.luisgustavoventura\.com$ [NC]
RewriteRule ^(.*)$ http://www.cbpq.org.br/$1 [L,NC,R=302]