Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除index.php,强制ssl,并将www重定向到.htaccess中的非www_.htaccess_Mod Rewrite_Ssl - Fatal编程技术网

删除index.php,强制ssl,并将www重定向到.htaccess中的非www

删除index.php,强制ssl,并将www重定向到.htaccess中的非www,.htaccess,mod-rewrite,ssl,.htaccess,Mod Rewrite,Ssl,我很感激这些问题被问得死去活来,但我似乎无法找到我需要的确切答案,所有与我最接近的问题都将非www重定向到www,但我需要相反的答案 所以,我想做的是强制www在任何时候都是非www的,从url中重写index.php,并强制站点在任何时候都是SSL 我有以下功能,除了强制SSL之外,其他功能都可以实现,我尝试了很多不同的方法,但总是得到无限循环: # Rewrite www to non www <IfModule mod_rewrite.c> RewriteCond %{H

我很感激这些问题被问得死去活来,但我似乎无法找到我需要的确切答案,所有与我最接近的问题都将非www重定向到www,但我需要相反的答案

所以,我想做的是强制www在任何时候都是非www的,从url中重写index.php,并强制站点在任何时候都是SSL

我有以下功能,除了强制SSL之外,其他功能都可以实现,我尝试了很多不同的方法,但总是得到无限循环:

# Rewrite www to non www

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>

Rewrite the index.php out

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
尝试更改此选项:

  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]

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