Php 强制用户将HTTPS与htaccess一起使用
在.htaccess文件中,我添加了此规则,以强制所有用户使用HTTPS访问网站Php 强制用户将HTTPS与htaccess一起使用,php,wordpress,apache,.htaccess,Php,Wordpress,Apache,.htaccess,在.htaccess文件中,我添加了此规则,以强制所有用户使用HTTPS访问网站 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{SERVER_PORT} !^443$ RewriteCond %{THE_REQUEST} !/(robots\.txt|sitemap\.xml|us_portfolio-sitemap.xml|post-sitemap.x
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{THE_REQUEST} !/(robots\.txt|sitemap\.xml|us_portfolio-sitemap.xml|post-sitemap.xml|page-sitemap.xml)\s [NC]
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^index\.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
重新启动发动机
重写条件%{HTTPS}关闭
重写cond%{SERVER\u PORT}^443$
重写cond%{THE_REQUEST}/(robots\.txt | sitemap\.xml | us|u portfolio-sitemap.xml | post sitemap.xml | page sitemap.xml)\s[NC]
重写规则^(.*)https://%{HTTP_HOST}%{REQUEST_URI}[R=301,L]
重写规则^index\.php-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
但当用户尝试访问时,它将被重定向到。
如果我呼叫,它将被正确重定向到
如何从url中删除/?/以便在正确的页面重定向用户?在新闻文件夹中是否有其他规则或htaccess?请尝试完全清除浏览器缓存并重新测试,因为此处没有显示将
/news
转换为?/news
的规则。这些是与mod\u rewrite相关的唯一规则。我还有其他规则:-mod_deflate.c-mod_headers.c-mod_expires.c-mod_gzip.c,但问题不在其他规则中…您使用这些规则进行测试,您永远不应该这样做。这个奇怪的重定向很可能是早期实验的遗留问题。谢谢@OlafDietsche的建议。但主要问题是什么?新闻文件夹中是否有其他规则或htaccess?请尝试完全清除浏览器缓存并重新测试,因为此处没有显示将/news
转换为?/news
的规则,这些是与mod_rewrite相关的唯一规则。我还有其他规则:-mod_deflate.c-mod_headers.c-mod_expires.c-mod_gzip.c,但问题不在其他规则中…您使用这些规则进行测试,您永远不应该这样做。这个奇怪的重定向很可能是早期实验的遗留问题。谢谢@OlafDietsche的建议。但主要问题是什么呢?