В моем файле https на Drupal я хочу, чтобы каждая возможность URL в конечном итоге перенаправляла на https www site org (обратите внимание на 's' и 'www')
Я могу получить следующее работает:
Я не могу получить:
Вот код https:
# Set "protossl" to "s" if we were accessed via https://. This is used later
# if you enable "www." stripping or enforcement, in order to ensure that
# you don't bounce between http and https.
RewriteEngine on
RewriteRule ^ - [E=protossl:s]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/foo will be redirected to http://www.example.com/foo)
# uncomment the following:
# RewriteCond %{HTTP_HOST} .
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Спасибо за ваш help
# RewriteCond% {HTTP_HOST}. # RewriteCond% {HTTP_HOST}! ^ Www \. [NC] # RewriteRule ^ http% {ENV: protossl}: //www.% {HTTP_HOST}% {REQUEST_URI} [L, R = 301]
В опубликованном вами коде последняя часть ( закомментирована ) выглядит так, как будто она должна делать то, что вам нужно, поэтому вам просто нужно раскомментировать эти последние 3 строки!?
Однако вам следует также измените порядок этих директив, чтобы избежать множественных перенаправлений при запросе URL-адреса вида http://example.com
.
Например:
RewriteEngine on
# Set "protossl" to "s" if we were accessed via https://. This is used later
# if you enable "www." stripping or enforcement, in order to ensure that
# you don't bounce between http and https.
RewriteRule ^ - [E=protossl:s]
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/foo will be redirected to http://www.example.com/foo)
# uncomment the following:
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# HTTP to HTTPS redirect (By this stage the HTTP_HOST is already canonicalised)
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Other...
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Как всегда, очистите кеш браузера перед тестированием .