我最近将网站改为HTTPS,在该网站使用非www和www url版本之前。
现在我把网站改为HTTPS,并被迫从非www转到www.
例如,对于旧的http+www urls,一切都很好:
旧url
http://www.example.com/about-us.html新url
https://www.example.com/about-us.html在这种情况下,旧的url将完全重定向到新的url,没有问题。
但是,只要旧的url不是WWW,它就会重定向到HTTPS,但是重定向到index.php页面,而不是整个路径。例如
旧url
http://example.com/about-us.html OR https://example.com/about-us.html这个重定向的url将是
https://www.example.com/ INSTEAD OF **https://www.example.com/about-us.html**这是我写的htaccess,我想不出更多的东西了..有人能帮忙吗。谢谢
php_flag eaccelerator.enable 1
php_flag eaccelerator.optimizer 1
Options +FollowSymLinks
RewriteEngine On
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
# RewriteBase /
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTPS:Authorization}]
RewriteCond %{HTTP_HOST} ^ip29\.216-86-153\.static\.steadfast\.net$ [NC]
RewriteRule ^(.*)$ https://www.example.com$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^216\.86\.153\.29
RewriteRule ^(.*)$ https://www.example.com$1 [R=301,L]
RewriteRule ^alcatel-7404.html(.*)$ https://www.example.com/alcatel-lucent/alcatel-7404.html$1 [r=301,nc]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
RewriteCond %{HTTPS} OFF
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]希望有人能帮忙。谢谢
发布于 2016-04-20 11:02:52
若要将http重定向到https://www,可以使用
RewriteCond %{HTTPS} OFF [NC]
RewriteCond www.%{HTTP_HOST} ^(?:www\.)?(www\..+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [NE,L,R]https://stackoverflow.com/questions/36741507
复制相似问题