首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >joomla htaccess 2步重定向

joomla htaccess 2步重定向
EN

Stack Overflow用户
提问于 2016-04-20 10:50:18
回答 1查看 70关注 0票数 1

我最近将网站改为HTTPS,在该网站使用非www和www url版本之前。

现在我把网站改为HTTPS,并被迫从非www转到www.

例如,对于旧的http+www urls,一切都很好:

旧url

代码语言:javascript
复制
http://www.example.com/about-us.html

新url

代码语言:javascript
复制
https://www.example.com/about-us.html

在这种情况下,旧的url将完全重定向到新的url,没有问题。

但是,只要旧的url不是WWW,它就会重定向到HTTPS,但是重定向到index.php页面,而不是整个路径。例如

旧url

代码语言:javascript
复制
http://example.com/about-us.html OR https://example.com/about-us.html

这个重定向的url将是

代码语言:javascript
复制
https://www.example.com/ INSTEAD OF **https://www.example.com/about-us.html**

这是我写的htaccess,我想不出更多的东西了..有人能帮忙吗。谢谢

代码语言:javascript
复制
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]

希望有人能帮忙。谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-20 11:02:52

若要将http重定向到https://www,可以使用

代码语言:javascript
复制
RewriteCond %{HTTPS} OFF [NC]
RewriteCond www.%{HTTP_HOST} ^(?:www\.)?(www\..+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [NE,L,R]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36741507

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档