【发布时间】:2015-06-11 22:48:46
【问题描述】:
我在我的 htacess 文件中添加了一些行来将所有 http 请求重定向到 https。现在,当我输入如下 URL 时:http://example.com/frames/view/4701362,它会重定向到:https://example.com/index.php?q=frames/view/4701362。我可以手动转到该页面:https://example.com/frames/view/4701362,并且 URL 不会更改。
我设置了干净的 URL
Htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine on
#some more stuff here, unrelated
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
编辑: 我尝试像这样反转 Drupal index.php?q= 行和 https 行...
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
但后来我的网站没有正确加载,并说即使在主页上也找不到页面。
【问题讨论】:
-
看起来它正在按照您的规则执行。你想让它表现得不同吗?
-
如果我输入 _http://example.com/frames 我希望它重定向到 _https://example.com/frames 而不是 _https://example.com/index.php?q =frames(忽略下划线)
-
第一个重写规则负责该更改,第二个负责 HTTPS 切换。看起来您只需要第二个,所以请尝试消除第一个。
-
我认为这是 Drupal 放在那里的东西
-
我其实觉得需要切换一下……先HTTPS重定向,再重写到index.php
标签: .htaccess mod-rewrite https drupal-6 clean-urls