带子域的重定向注册失败



我有几个域,我有一些规则在我的。htaccess文件重定向目录一级,如:

RewriteCond %{HTTP_HOST} ^www.example1.com$ [NC]
RewriteRule ^it/foo.php$ https://www.example1.com/foo.php [R=301,L]

这个效果很好。但我现在尝试对子域或不同的域做同样的事情:

RewriteCond %{HTTP_HOST} ^sub.example2.com$ [NC]
RewriteRule ^it/foo.php$ https://sub.example2.com/foo.php [R=301,L]

这个重定向永远不会发生。我想这可能与重定向到www:

有关。
RewriteCond %{HTTP_HOST} ^example2.com$ [NC]
RewriteRule ^(.*)$ http://www.example2.com/$1 [R=301,L]

但是,即使把它注释掉,也会产生同样的问题。知道我哪里做错了吗?

编辑:

VirtualHost配置是相当基本的,仅用于SSL:

<VirtualHost *:443>
DocumentRoot "/var/www/html"
ServerName www.example2.com
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/.....crt
SSLCertificateKeyFile /etc/pki/tls/private/.....key
SSLCertificateChainFile /etc/pki/tls/certs/.....ca-bundle
CustomLog logs/ssl_request_log 
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x "%r" %b"
</VirtualHost>

编辑# 2:

htaccess:

RewriteEngine On
#CMS SEF stuff that's needed
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|.(php|html?|feed|pdf|raw|ini|zip|json|file|vcf))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
RewriteCond %{HTTP_HOST} ^sub.example2.com$ [NC]
RewriteRule ^it/foo.php$ https://sub.example2.com/foo.php [R=301,L]

在.htaccess中试试这段代码:

RewriteEngine On
#CMS SEF stuff that's needed
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{HTTP_HOST} ^sub.example2.com$ [NC]
RewriteRule ^it/foo.php$ https://sub.example2.com/foo.php [R=301,L,NE]
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|.(php|html?|feed|pdf|raw|ini|zip|json|file|vcf))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

最新更新