htaccess - 301重定向问题

时间:2012-08-13 01:06:31

标签: .htaccess

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> 

1 个答案:

答案 0 :(得分: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 .....让我把它们放在主题中你可以看看。

这只是猜测,但您似乎没有任何vhost设置来处理jlcustompc.net,只有www.jlcustompc.net。在www.jlcustompc.net vhosts下,您应该添加:

ServerAlias jlcustompc.net

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