【问题标题】:joomla htaccess 2 steps redirectjoomla htaccess 2 步重定向
【发布时间】: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


    【解决方案1】:

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

    RewriteCond %{HTTPS} OFF [NC]
    RewriteCond www.%{HTTP_HOST} ^(?:www\.)?(www\..+)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [NE,L,R]
    

    【讨论】:

    • 从您的 htaccess 中删除最后 2 条规则,将其添加到“RewriteEngine on”行下方并清除浏览器缓存。
    • 是是是!!!它起作用了))我对您的代码所做的唯一更改是添加了 https 而不是 http!非常感谢!!
    猜你喜欢
    • 1970-01-01
    • 2013-04-22
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 2016-12-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多