【发布时间】:2016-02-18 05:06:35
【问题描述】:
我正在使用 .htaccess 创建对 seo 友好的 url,并将我的 HTTP 请求重定向到 HTTPS
当我不使用 HTTP 到 HTTPS 规则时,我的 url 显示 即http://www.domain.com,当有人点击用户名时,url 变为http://www.domain.com/username
但是当我使用 HTTP 到 HTTPS 规则时,当我单击用户名时它会干扰 url 即https://www.domain.com,当有人点击用户名时,网址将更改为https://www.domain.com/username?d=username
当我使用 HTTP 到 HTTPS 规则时,我想要它,然后单击用户名,我的 url 看起来像 即https://www.domain.com,当有人点击用户名时,网址将更改为https://www.domain.com/username
问题在于https://www.domain.com/username?d=username 网址
这是我的 .htaccess 代码
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?d=$1
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
【问题讨论】:
-
将第一条规则移到底部并清除浏览器缓存
标签: apache .htaccess mod-rewrite rewrite