将 HTTP 请求重定向到 HTTPS 会干扰我的 seo 友好 url
Redirecting HTTP requests to HTTPS interferes with my seo friendly url
我正在使用 .htaccess 创建 seo 友好 url 并将我的 HTTP 请求重定向到 HTTPS
当我不使用 HTTP 到 HTTPS 规则时,我的 url 读取
即 http://www.domain.com and when some one clicks username the url changes to http://www.domain.com/username
但是当我使用 HTTP 到 HTTPS 规则时,它会干扰 url 当我点击用户名时
即 https://www.domain.com and when some one clicks username the url changes to https://www.domain.com/username?d=username
当我使用 HTTP 到 HTTPS 规则时我会想要它,我单击用户名 my urls 看起来像
即 https://www.domain.com and when some one clicks username the url changes to https://www.domain.com/username
问题是 https://www.domain.com/username?d=username url
这是我的 .htaccess 代码
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?d=
#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]
将您的重定向放在首位并使用 L 标志。如果您使用您的域名,您也可以合并规则。
RewriteEngine On
#redirect to https and/or www/https
RewriteCond %{HTTP_HOST} ^domain\.com [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.domain.com/ [L,R=301]
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?d= [L]
我正在使用 .htaccess 创建 seo 友好 url 并将我的 HTTP 请求重定向到 HTTPS
当我不使用 HTTP 到 HTTPS 规则时,我的 url 读取 即 http://www.domain.com and when some one clicks username the url changes to http://www.domain.com/username
但是当我使用 HTTP 到 HTTPS 规则时,它会干扰 url 当我点击用户名时 即 https://www.domain.com and when some one clicks username the url changes to https://www.domain.com/username?d=username
当我使用 HTTP 到 HTTPS 规则时我会想要它,我单击用户名 my urls 看起来像 即 https://www.domain.com and when some one clicks username the url changes to https://www.domain.com/username
问题是 https://www.domain.com/username?d=username url
这是我的 .htaccess 代码
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?d=
#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]
将您的重定向放在首位并使用 L 标志。如果您使用您的域名,您也可以合并规则。
RewriteEngine On
#redirect to https and/or www/https
RewriteCond %{HTTP_HOST} ^domain\.com [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.domain.com/ [L,R=301]
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?d= [L]