【发布时间】:2017-07-15 20:30:26
【问题描述】:
在解决了我的 issue 以避免重定向 URL 的特定部分之后,我现在正在尝试解决将较长、更复杂的 URL 重定向到 https 的问题
这是我的 .htaccess 文件中给我问题的行:
RewriteRule ^(.+)$ index.php?uri=$1 [QSA,L]
index.php 永远不会在 URL 本身中公开。例如,此 URL 应重定向到 https:
输入网址后重定向到:
[https://bootstrapcovers.com/index.php?uri=themes/bootstrap-themes/toolsmith-1110/volvox-responsive-html5-bootstrap-template][2]
请注意,添加了 index.php?uri=,这是我所期望的,但页面被重定向回主页。如果我删除该部分 (index.php?uri=),则 url 有效!
如何在不添加 index.php?uri= 的情况下重定向 URL?
这是我完整的 .htaccess 文件:
# 1 Month for most static assets
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico|woff)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
Options -MultiViews
RewriteEngine on
RewriteRule ^(.+?)/$ /$1 [R=302,NE,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?uri=$1 [QSA,L]
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !\s/+preview [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} \s/+preview [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
我们将不胜感激任何解决此问题的帮助。
谢谢, -保罗
【问题讨论】:
标签: php apache .htaccess ssl https