Apache .htaccess,强制HTTPS并删除index.php

Apache .htaccess,强制HTTPS并删除index.php,apache,.htaccess,redirect,mod-rewrite,Apache,.htaccess,Redirect,Mod Rewrite,我知道有多个帖子,但我不能用其他答案来解决 我确实试过了,但没有成功 我的网站有一个index.php,可以执行路由器。因此,实际上是从index.php管理一个链接“/about”(在链接中删除) 这是我当前的访问权限: <IfModule mod_rewrite.c> RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} !^www\..+$ [NC] RewriteCond %{HTTP_HOST} !=

我知道有多个帖子,但我不能用其他答案来解决

我确实试过了,但没有成功

我的网站有一个index.php,可以执行路由器。因此,实际上是从index.php管理一个链接“/about”(在链接中删除)

这是我当前的访问权限:

<IfModule mod_rewrite.c>

    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
    RewriteCond %{HTTP_HOST} !=localhost [NC]
    RewriteCond %{HTTP_HOST} !=127.0.0.1
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    RewriteCond %{THE_REQUEST} ^.*/index.php 
    RewriteRule ^(.*)index.php$ %{HTTP_HOST}/$1/ [R=301,L]

</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L,QSA]

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?!localhost$|127\.0\.0\.1$)(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]

RewriteCond %{THE_REQUEST} /index.php [NC]
RewriteRule ^(.*)index\.php$ /$1/ [R=301,L,NC,NE]
现在它重写一个
http://www.example.com/apiv2/member-card?id=12
in
https://www.example.com/www.example.com//?id=12
具有双域。。。。。
http://example.com/apiv2/member-card?id=12
https://www.example.com/www.example.com//?id=12

您的第一条规则需要有
[或]
子句来重定向这两种情况:

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?!localhost$|127\.0\.0\.1$)(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]

RewriteCond %{THE_REQUEST} /index.php [NC]
RewriteRule ^(.*)index\.php$ /$1/ [R=301,L,NC,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

在测试此更改之前,请确保清除浏览器缓存。

使用代理权限如何?非常感谢。但是根据您的规则,这个link:get redirect to it会删除中间层中的所有内容no这个规则不会从URI中删除任何内容,因为我使用的是
%{REQUEST_URI}
,它是完整的URI。您的.htaccess中可能有其他规则,能否发布完整的.htaccess谢谢。在我最初的问题中,整个HTC访问。非常感谢你,因为你的规则顺序不对。请使用完整的.htaccess查看我的更新答案。清除浏览器缓存后进行测试。很遗憾,没有。使用.htaccess,每个请求都会进入404,并且不会重定向到https版本:(