我在使用客户端SSL证书时使用apache rewriterule来重定向url。当我使用[P]代理标志重定向到静态页面时,一切都按预期工作。但是如果我在wordpress中将重定向更改为页面,则键入的url会消失,并且会出现wordpress页面永久链接。我想在地址栏中保留未更改的类型网址,只是为了能够在连接到VPN或使用正确的证书后使用重新加载。
虚拟主机配置中使用的RewriteRules。
# SSL User Authentication
SSLVerifyClient optional
SSLVerifyDepth 3
# redirect all url when not in VPN or LOCAL NET
#RedirectMatch ^/(.*) http://terminus.terminus.cz
# to be able to debug rewrite in apache2 error log
LogLevel alert rewrite:trace6
# Error handling = unsuccessfull SSL user authetication
RewriteEngine on
Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
# No authentification certificate
RewriteCond %{SSL:SSL_CLIENT_VERIFY} !^SUCCESS$
RewriteCond %{HTTP_HOST} ^trading\.terminus\.cz$ [NC]
# RewriteCond {HTTP_REFERER} value is blank
RewriteCond %{HTTP_REFERER} ^$
RewriteRule ^ http://terminus.terminus.cz/no_ssl_client_certificate.htm [L,NE,P,E=ssl_authentication_error_detected:1]
# RewriteRule show typed domain name, proxying to other domain, same query
#RewriteRule ^ http://terminus.terminus.cz%{REQUEST_URI} [L,NE,P,E=ssl_authentication_error_detected:1]
# RewriteCond {HTTP_REFERER} value is not blank
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{SSL:SSL_CLIENT_VERIFY} !^SUCCESS$
RewriteCond %{HTTP_HOST} ^trading\.terminus\.cz$ [NC]
# RewriteRule show typed domain name, proxying to other domain, same query
RewriteRule ^ http://terminus.terminus.cz%{REQUEST_URI} [L,NE,P,E=ssl_authentication_error_detected:1]
当我将代理网址更改为
时RewriteRule ^ http://terminus-dev.terminus.cz/index.php/no_ssl_certificate [L,NE,P,E=ssl_authentication_error_detected:1]
它开始将地址栏中键入的URL更改为wordpress固定链接,因此[P]标志无法正常工作。
来自wordpress虚拟主机访问日志
37.48.19.237 - - [19/Jul/2016:09:28:42 +0200] "GET /index.php/no-ssl-certificate/ HTTP/1.1" 200 17126 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:43 +0200] "GET /wp-includes/js/wp-emoji-release.min.js?ver=4.5.3 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:43 +0200] "GET /wp-content/plugins/theme-my-login/theme-my-login.css?ver=6.4.5 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:43 +0200] "GET /wp-content/plugins/wp-filebase/wp-filebase.css?t=1467256824&ver=3.4.4 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:43 +0200] "GET /wp-content/plugins/llorix-one-companion//css/style.css?ver=4.5.3 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:43 +0200] "GET /wp-content/plugins/wordpress-social-login/assets/css/style.css?ver=4.5.3 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:43 +0200] "GET /wp-content/themes/llorix-one-lite/css/font-awesome.min.css?ver=4.4.0 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:43 +0200] "GET /wp-content/themes/llorix-one-lite/css/bootstrap.min.css?ver=3.3.1 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:44 +0200] "GET /wp-content/themes/llorix-one-lite/style.css?ver=1.0.0 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:44 +0200] "GET /wp-includes/js/jquery/jquery.js?ver=1.12.4 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:44 +0200] "GET /wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:44 +0200] "GET /wp-content/themes/llorix-one-lite/js/bootstrap.min.js?ver=3.3.5 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:44 +0200] "GET /wp-content/themes/llorix-one-lite/fonts/fontawesome-webfont.woff?v=4.5.0 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:44 +0200] "GET /wp-content/themes/llorix-one-lite/js/custom.all.js?ver=2.0.2 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:44 +0200] "GET /wp-content/themes/llorix-one-lite/js/skip-link-focus-fix.js?ver=1.0.0 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
37.48.19.237 - - [19/Jul/2016:09:28:44 +0200] "GET /wp-includes/js/wp-embed.min.js?ver=4.5.3 HTTP/1.1" 304 - "http://terminus-dev.terminus.cz/index.php/no-ssl-certificate/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586"
答案 0 :(得分:0)
redirect_canonical过滤器负责url重写。因此,有可能根据请求的页面选择性地禁用它。
通过将以下代码放置到主题function.php
来解决function ssl_certicate_pages_disable_canonical_redirect( $query ) {
if( 'no_ssl_certificate' == $query->query_vars['pagename'] )
remove_filter( 'template_redirect', 'redirect_canonical' );
if( 'wrong_ssl_certificate' == $query->query_vars['pagename'] )
remove_filter( 'template_redirect', 'redirect_canonical' );
}
add_action( 'parse_query', 'ssl_certicate_pages_disable_canonical_redirect' );