【发布时间】:2016-04-20 10:50:18
【问题描述】:
我最近将站点更改为 HTTPS,并且在站点使用非 www 和 www url 版本之前..
现在我将站点更改为 HTTPS 并强制从非 www 重定向到 www...
对于旧的 http+www 网址,一切正常,例如:
旧网址
http://www.example.com/about-us.html
新网址
https://www.example.com/about-us.html
在这种情况下,旧网址将完全重定向到新网址,没问题
但是一旦旧的 url 是 NON-WWW,它就会重定向到 HTTPS,但会重定向到 index.php 页面而不是完整路径。例如
旧网址
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]
希望有人可以提供帮助。谢谢
【问题讨论】:
标签: php .htaccess url redirect joomla