重写规则以将别名域重定向到主域并且路径不起作用

时间:2015-10-26 19:39:21

标签: .htaccess mod-rewrite

我正在尝试将别名域的请求重定向到主域上的特定路径,我没有收到任何错误,但重定向无法正常工作。我认为在初始规则之后还有其他东西会重定向。

这是.htaccess文件。

Options +FollowSymLinks

RewriteEngine On

RewriteBase /

# these are the rules that are not working
RewriteCond %{HTTP_HOST} ^www.alias-domain\.com$ [NC]
RewriteRule (.*)$ http://www.domain.com/path/path/ [R=301,L]

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

# The Friendly URLs part
# detect language when requesting the root (/)
RewriteCond %{HTTP:Accept-Language} !^org [NC]
RewriteRule ^$ en/ [R=301,L]
RewriteRule ^$ fr/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(en|fr|org)/favicon.ico$ favicon.ico [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(en|fr|org)/assets(.*)$ assets$2 [L,QSA]

# to index.php and set the cultureKey parameter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(en|fr|org)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]

任何人都知道为什么别名域没有重定向到域?

更新 按要求~vhost.conf

<IfModule mod_ssl.c>

    <VirtualHost 123.123.123.123:443 >
        ServerName "domaindomain.com:443"
        ServerAlias "www.domaindomain.com"
        ServerAlias "ipv4.domaindomain.com"
        ServerAlias "factorsusa.com"
        ServerAlias "www.factorsusa.com"
        ServerAlias "ipv4.factorsusa.com"
        ServerAlias "factorscanada.com"
        ServerAlias "www.factorscanada.com"
        ServerAlias "ipv4.factorscanada.com"
        ServerAlias "factorscanada.ca"
        ServerAlias "www.factorscanada.ca"
        ServerAlias "ipv4.factorscanada.ca"
        ServerAlias "domaindomain.ca"
        ServerAlias "www.domaindomain.ca"
        ServerAlias "ipv4.domaindomain.ca"
        ServerAlias "domaincredit.com"
        ServerAlias "www.domaincredit.com"
        ServerAlias "ipv4.domaincredit.com"
        ServerAlias "domaindomain.co"
        ServerAlias "www.domaindomain.co"
        ServerAlias "ipv4.domaindomain.co"
        ServerAlias "domaindomainltd.com"
        ServerAlias "www.domaindomainltd.com"
        ServerAlias "ipv4.domaindomainltd.com"
        ServerAlias "domaindomainltd.ca"
        ServerAlias "www.domaindomainltd.ca"
        ServerAlias "ipv4.domaindomainltd.ca"
        ServerAlias "domaindomain.ca"
        ServerAlias "www.domaindomain.ca"
        ServerAlias "ipv4.domaindomain.ca"
        ServerAlias "domaindomain.co"
        ServerAlias "www.domaindomain.co"
        ServerAlias "ipv4.domaindomain.co"
        ServerAlias "domaindomain.com"
        ServerAlias "www.domaindomain.com"
        ServerAlias "ipv4.domaindomain.com"
        ServerAlias "domaindomain.net"
        ServerAlias "www.domaindomain.net"
        ServerAlias "ipv4.domaindomain.net"
        ServerAlias "domaindomain.lease"
        ServerAlias "www.domaindomain.lease"
        ServerAlias "ipv4.domaindomain.lease"
        ServerAlias "domaindomainus.com"
        ServerAlias "www.domaindomainus.com"
        ServerAlias "ipv4.domaindomainus.com"
        ServerAdmin "rowens@domaindomain.com"
        UseCanonicalName Off

        DocumentRoot "/var/www/vhosts/domaindomain.com/httpdocs"
        CustomLog /var/www/vhosts/system/domaindomain.com/logs/access_ssl_log plesklog
        ErrorLog "/var/www/vhosts/system/domaindomain.com/logs/error_log"

        <IfModule mod_suexec.c>
            SuexecUserGroup "domain" "psacln"
        </IfModule>

        <IfModule mod_userdir.c>
            UserDir "/var/www/vhosts/domaindomain.com/web_users"
        </IfModule>

        <IfModule mod_sysenv.c>
            SetSysEnv PP_VHOST_ID ""
        </IfModule>

        SSLEngine on
        SSLVerifyClient none
        SSLCertificateFile /usr/local/psa/var/certificates/cert-C
        SSLCACertificateFile /usr/local/psa/var/certificates/cert-q
        SetEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/domaindomain.com/etc/php.ini
        SetEnv PP_CUSTOM_PHP_CGI_INDEX module

        <IfModule mod_fcgid.c>
            FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/domaindomain.com/etc/php.ini
            FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX module
            FcgidMaxRequestLen 13421
        </IfModule>

        <Directory /var/www/vhosts/domaindomain.com/httpdocs>

            <IfModule sapi_apache2.c>
                php_admin_flag engine on
            </IfModule>

            <IfModule mod_php5.c>
                php_admin_flag engine on
            </IfModule>

            SSLRequireSSL

            Options -Includes -ExecCGI

        </Directory>

        <Directory /var/www/vhosts/domaindomain.com/web_users>

            <IfModule sapi_apache2.c>
                php_admin_flag engine off
            </IfModule>

            <IfModule mod_php5.c>
                php_admin_flag engine off
            </IfModule>

        </Directory>

        Alias /error_docs /var/www/vhosts/domaindomain.com/error_docs
        ErrorDocument 400 /error_docs/bad_request.html
        ErrorDocument 401 /error_docs/unauthorized.html
        ErrorDocument 403 /error_docs/forbidden.html
        ErrorDocument 404 /error_docs/not_found.html
        ErrorDocument 500 /error_docs/internal_server_error.html
        ErrorDocument 405 /error_docs/method_not_allowed.html
        ErrorDocument 406 /error_docs/not_acceptable.html
        ErrorDocument 407 /error_docs/proxy_authentication_required.html
        ErrorDocument 412 /error_docs/precondition_failed.html
        ErrorDocument 414 /error_docs/request_uri_too_long.html
        ErrorDocument 415 /error_docs/unsupported_media_type.html
        ErrorDocument 501 /error_docs/not_implemented.html
        ErrorDocument 502 /error_docs/bad_gateway.html
        ErrorDocument 503 /error_docs/maintenance.html

        <IfModule mod_security2.c>
        </IfModule>

    </VirtualHost>

</IfModule>

<VirtualHost 123.123.123.123:80 >
    ServerName "domain.com:80"
    ServerAlias "www.domaindomain.com"
    ServerAlias "ipv4.domaindomain.com"
    ServerAlias "factorsusa.com"
    ServerAlias "www.factorsusa.com"
    ServerAlias "ipv4.factorsusa.com"
    ServerAlias "factorscanada.com"
    ServerAlias "www.factorscanada.com"
    ServerAlias "ipv4.factorscanada.com"
    ServerAlias "factorscanada.ca"
    ServerAlias "www.factorscanada.ca"
    ServerAlias "ipv4.factorscanada.ca"
    ServerAlias "domaindomain.ca"
    ServerAlias "www.domaindomain.ca"
    ServerAlias "ipv4.domaindomain.ca"
    ServerAlias "domaincredit.com"
    ServerAlias "www.domaincredit.com"
    ServerAlias "ipv4.domaincredit.com"
    ServerAlias "domaindomain.co"
    ServerAlias "www.domaindomain.co"
    ServerAlias "ipv4.domaindomain.co"
    ServerAlias "domaindomainltd.com"
    ServerAlias "www.domaindomainltd.com"
    ServerAlias "ipv4.domaindomainltd.com"
    ServerAlias "domaindomainltd.ca"
    ServerAlias "www.domaindomainltd.ca"
    ServerAlias "ipv4.domaindomainltd.ca"
    ServerAlias "domaindomain.ca"
    ServerAlias "www.domaindomain.ca"
    ServerAlias "ipv4.domaindomain.ca"
    ServerAlias "domaindomain.co"
    ServerAlias "www.domaindomain.co"
    ServerAlias "ipv4.domaindomain.co"
    ServerAlias "domaindomain.com"
    ServerAlias "www.domaindomain.com"
    ServerAlias "ipv4.domaindomain.com"
    ServerAlias "domaindomain.net"
    ServerAlias "www.domaindomain.net"
    ServerAlias "ipv4.domaindomain.net"
    ServerAlias "domaindomain.lease"
    ServerAlias "www.domaindomain.lease"
    ServerAlias "ipv4.domaindomain.lease"
    ServerAlias "domaindomainus.com"
    ServerAlias "www.domaindomainus.com"
    ServerAlias "ipv4.domaindomainus.com"
    ServerAdmin "rowens@domaindomain.com"
    UseCanonicalName Off

    DocumentRoot "/var/www/vhosts/domaindomain.com/httpdocs"
    CustomLog /var/www/vhosts/system/domaindomain.com/logs/access_log plesklog
    ErrorLog "/var/www/vhosts/system/domaindomain.com/logs/error_log"

    <IfModule mod_suexec.c>
        SuexecUserGroup "domain" "psacln"
    </IfModule>

    <IfModule mod_userdir.c>
        UserDir "/var/www/vhosts/domaindomain.com/web_users"
    </IfModule>

    <IfModule mod_sysenv.c>
        SetSysEnv PP_VHOST_ID ""
    </IfModule>

    <IfModule mod_ssl.c>
        SSLEngine off
    </IfModule>

    SetEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/domaindomain.com/etc/php.ini
    SetEnv PP_CUSTOM_PHP_CGI_INDEX module

    <IfModule mod_fcgid.c>
        FcgidInitialEnv PP_CUSTOM_PHP_INI /var/www/vhosts/system/domaindomain.com/etc/php.ini
        FcgidInitialEnv PP_CUSTOM_PHP_CGI_INDEX module
        FcgidMaxRequestLen 1342
    </IfModule>

    <Directory /var/www/vhosts/domaindomain.com/httpdocs>

        <IfModule sapi_apache2.c>
            php_admin_flag engine on
        </IfModule>

        <IfModule mod_php5.c>
            php_admin_flag engine on
        </IfModule>

        Options -Includes -ExecCGI

    </Directory>

    <Directory /var/www/vhosts/domaindomain.com/web_users>

        <IfModule sapi_apache2.c>
            php_admin_flag engine off
        </IfModule>

        <IfModule mod_php5.c>
            php_admin_flag engine off
        </IfModule>

    </Directory>

    Alias /error_docs /var/www/vhosts/domaindomain.com/error_docs
    ErrorDocument 400 /error_docs/bad_request.html
    ErrorDocument 401 /error_docs/unauthorized.html
    ErrorDocument 403 /error_docs/forbidden.html
    ErrorDocument 404 /error_docs/not_found.html
    ErrorDocument 500 /error_docs/internal_server_error.html
    ErrorDocument 405 /error_docs/method_not_allowed.html
    ErrorDocument 406 /error_docs/not_acceptable.html
    ErrorDocument 407 /error_docs/proxy_authentication_required.html
    ErrorDocument 412 /error_docs/precondition_failed.html
    ErrorDocument 414 /error_docs/request_uri_too_long.html
    ErrorDocument 415 /error_docs/unsupported_media_type.html
    ErrorDocument 501 /error_docs/not_implemented.html
    ErrorDocument 502 /error_docs/bad_gateway.html
    ErrorDocument 503 /error_docs/maintenance.html

    Include "/var/www/vhosts/system/domaindomain.com/conf/vhost.conf"

    <IfModule mod_security2.c>
    </IfModule>

</VirtualHost>

0 个答案:

没有答案