简体   繁体   中英

How to exclude certain pages from the below rewrite condition

How to exclude /blog/wp-admin/ and /blog/wp-login.php from

RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ http://examplesite.com/blog/$1 [R=301,L]

So that those will skip and stay on https and everything else will pass through. In other words the below should not be affected by the rule:

_https://examplesite.com/blog/wp-admin/
_https://examplesite.com/blog/wp-login.php

How can this be achieved? I have tried adding the below as a second condition but it doesn't do the trick:

RewriteCond %{REQUEST_URI} !^/?(wp-admin/|wp-login\.php)

This seems to work for me ok. However if the are browsing using the /blog in the URL then it needs to be in the condition also. Try this rule below how I have it.

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/(blog/)?(wp-admin/?$|wp-login\.php)
RewriteRule ^(.*)$ http://examplesite.com/blog/$1 [R=301,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM