我们从第三方提供商处购买了一些软件,然后开始安装 ssl 证书...当我们转到该站点的 http 版本时,一切正常,但是当我们转到 https 时,浏览器会在末尾添加两个斜杠根 url,并重定向回 http 站点...我不知道如何阅读重写规则,但我们希望站点执行完全相同的操作,无论是 http 还是 https...有没有简单的更新方法这个:
DirectoryIndex index.html index.php
ErrorDocument 404 /handler.php
RewriteEngine on
Options +FollowSymlinks
RewriteBase /code
RewriteRule manage_articles\.php /code/load_module.php?module_name=articles&file=manage_articles&%{QUERY_STRING} [L]
RewriteRule manage_articles_cat_frame\.php /code/load_module.php?module_name=articles&file=manage_articles_cat_frame&%{QUERY_STRING} [L]
RewriteRule manage_articles_categories\.php /code/load_module.php?module_name=articles&file=manage_articles_categories&%{QUERY_STRING} [L]
RewriteRule modify_article\.php /code/load_module.php?module_name=articles&file=modify_article&%{QUERY_STRING} [L]
RewriteRule modify_article_cat\.php /code/load_module.php?module_name=articles&file=modify_article_cat&%{QUERY_STRING} [L]
RewriteRule manage_letters\.php /code/load_module.php?module_name=letters&file=manage_letters&%{QUERY_STRING} [L]
RewriteRule modify_letters\.php /code/load_module.php?module_name=letters&file=modify_letters&%{QUERY_STRING} [L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\/]+)\.html$ article.php?path=$1&%{QUERY_STRING} [L]
RewriteRule ^([^\/]+)\.htm$ article.php?cat_path=$1&%{QUERY_STRING} [L]
RewriteRule ^(article_[^\.]+\.gif)$ modules/articles/images/$1 [L]
RewriteRule ^auctions\/([^\/]+)\/*$ auction.php?title=$1&%{QUERY_STRING} [L]
RewriteRule ^auctions\/([^\/]+)\/buy_now$ buy_product.php?title=$1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_URI} !^(.*)(gif|jpg|css|png|js)$
RewriteRule ^.htaccess$ - [F]
# api rewrite logic
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^services\/(.*)$ services/api.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^services\/(.*)$ services/api.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^services\/(.*)$ services/api.php [QSA,NC,L]
#end api rewrite
同样,我希望网站的功能完全相同,也只需处理 https。
谢谢。
添加 vhosts.conf:
# linkz.com ssl
<VirtualHost 164.175.65.135:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /usr/local/ssl/crt/publicbz.crt
SSLCertificateKeyFile /usr/local/ssl/private/private_nopp_bz.key
SSLCertificateChainFile /usr/local/ssl/crt/intermediate.crt
ServerAdmin webmaster@linkz.com
DocumentRoot /usr/local/www/micro
<Directory "/usr/local/www/micro">
AllowOverride All
DirectoryIndex index.html index.php
</Directory>
ServerName www.linkz.com
ServerAlias linkz.com
ErrorLog /var/log/httpd/linkz.error.log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost 164.175.65.135:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /usr/local/ssl/crt/publicbz.crt
SSLCertificateKeyFile /usr/local/ssl/private/private_nopp_bz.key
SSLCertificateChainFile /usr/local/ssl/crt/intermediate.crt
ServerAdmin webmaster@linkz.com
DocumentRoot /usr/local/www/microdev
<Directory "/usr/local/www/microdev">
AllowOverride All
DirectoryIndex index.html index.php
</Directory>
ServerName dev.linkz.com
ServerAlias dev.linkz.com
ErrorLog /var/log/httpd/linkzdev.error.log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
# # # # # # # # # # # # # # # # # # # # # # # # # # #
# linkz.com
<VirtualHost 164.175.65.135:80>
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /usr/local/www/micro
<Directory "/usr/local/www/micro">
AllowOverride All
DirectoryIndex index.html index.php
</Directory>
ServerName www.linkz.com
ServerAlias linkz.com
ErrorLog /var/log/httpd/linkz.error.log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost 164.175.65.135:80>
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /usr/local/www/microdev
<Directory "/usr/local/www/microdev">
AllowOverride All
DirectoryIndex index.html index.php
</Directory>
ServerName dev.linkz.com
ServerAlias dev.linkz.com
ErrorLog /var/log/httpd/linkzdev.error.log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
添加 index.php:
if($_SERVER['SERVER_PORT']==443 && ($_SERVER['HTTP_HOST'] != 'www.auction.test' || $_SERVER['HTTP_HOST'] != 'www.default.loc'))
{
header('Location: '.$GLOBALS['SERVER_PATH'].$_SERVER['REQUEST_URI']);
exit;
}