0
RewriteEngine On
RewriteCond %{HTTP_HOST} ^jlcustompc.com [NC]
RewriteRule ^(.*)$ https://www.jlcustompc.com/$1 [L,R=301]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^jlcustompc.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.jlcustompc.net$
RewriteRule (.*)$ https://www.jlcustompc.com/$1 [R=301,L]

RedirectMatch 301 /contactform.php /buymypc.php

AddType application/x-httpd-php .html

AddType application/x-httpd-php .htm

RewriteCond %{HTTP_USER_AGENT} libwww-perl.* [NC,OR]

RewriteCond %{QUERY_STRING} ^(.*)=http [NC]

RewriteRule ^(.*)$ – [F,L]

我希望 jlcustompc.net 重定向到https://www.jlcustompc.com

这是我唯一遇到的问题。此外,如果您看到任何其他可以添加、替换或修改的内容,请告诉我。

这是我刚刚设置的虚拟主机,似乎没有按预期工作。

我认识的第一个主机毫无疑问是有效的。

<VirtualHost MYIP:443>
            ServerAdmin admin@jlcustompc.com
            DocumentRoot "ROOT"
            ServerName www.jlcustompc.com
            ErrorLog ERRORLOG
            SSLEngine on
            SSLProtocol all
            SSLCertificateFile "PATH"
            SSLCertificateKeyFile "PATH"
            SSLCACertificateFile "PATH"
            ServerPath "PATH"
            <Directory "PATH">
            </Directory>
</VirtualHost>  

<VirtualHost MYIP:443>
            ServerAdmin admin@jlcustompc.com
            DocumentRoot "PATH"
            ServerName www.jlcustompc.net
            ErrorLog ERRORLOG
            SSLEngine on
            SSLProtocol all
            SSLCertificateFile "PATH"
            SSLCertificateKeyFile "PATH"
            SSLCACertificateFile "PATH"
            ServerPath "PATH"
            <Directory "PATH">
            </Directory>
</VirtualHost> 

<VirtualHost MYIP:80>
            ServerAdmin admin@jlcustompc.com
            DocumentRoot "PATH"
            ServerName www.jlcustompc.net
            ErrorLog ERRORLOG
            ServerPath "PATH"
            <Directory "PATH">
            </Directory>
</VirtualHost> 

<VirtualHost MYIP:80>
            ServerAdmin admin@jlcustompc.com
            DocumentRoot "PATH"
            ServerName www.jlcustompc.com
            ErrorLog ERRORLOG
            ServerPath "PATH"
            <Directory "PATH">
            </Directory>
</VirtualHost> 
4

1 回答 1

0

您可以尝试替换所有这些:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^jlcustompc.com [NC]
RewriteRule ^(.*)$ https://www.jlcustompc.com/$1 [L,R=301]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^jlcustompc.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.jlcustompc.net$
RewriteRule (.*)$ https://www.jlcustompc.com/$1 [R=301,L]

简单地说:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.jlcustompc.com$ [NC]
RewriteRule ^(.*)$ https://www.jlcustompc.com/$1 [L,R=301]

编辑:

我在 httpd 中添加了虚拟主机设置.....我把它们放在主题中,你可以看看。

这只是一个猜测,但您似乎没有任何要处理的虚拟主机设置jlcustompc.net,只有www.jlcustompc.net. 在www.jlcustompc.net虚拟主机下,您应该添加:

ServerAlias jlcustompc.net

但看起来你也没有任何处理jlcustompc.com,但这似乎有效。

于 2012-08-13T02:19:25.523 回答