我想通过重新引导一些URL模式强制SSL www。
例如,
强制SSL wwwredirect:
http://example.com/asia/fewf -> https://www.example/asia/fewfwe http://example.com/africa/foo/bar/1/ -> https://www.example/africa/foo/bar/1/
不要做任何事:
http://example.com/europe/1 -> http://example.com/europe/1 http://www.example.com/europe/1 -> http://www.example.com/europe/1
我试着添加这个:
RedirectMatch 301 ^(/asia[^/]*/.*)$ https://www.example.com$1
但是,它会导致错误:“太重要的redirect”
我相信你得到太多的redirect的原因是因为RedirectMatch即使在https请求URL时也会被触发,所以即使它已经变成了https,它也会一遍又一遍地redirect。
我build议解决这个mod_rewrite。 例如:
RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule %{REQUEST_URI} ^(/asia[^/]*/.*)$ https://www.example.com$1 [R=301,L]
当你testing出来的时候,我build议不用R=301 ,只要有R因为这不会导致浏览器永久cachingredirect,这可能会使故障排除变得复杂。