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
.htaccess 强制HTTPS到一个目录-删除WWW_.htaccess_Http_Https - Fatal编程技术网

.htaccess 强制HTTPS到一个目录-删除WWW

.htaccess 强制HTTPS到一个目录-删除WWW,.htaccess,http,https,.htaccess,Http,Https,我有一个小问题,这是我用来强制https到签出目录的,只是一个预防措施,但问题是一旦你回到主页,它会将www插入URL 这是一个问题,因为视线的其余部分不使用www,有人能建议如何添加此选项以删除/保留www吗 # force https for all URLs in /checkout RewriteCond %{HTTPS} =off RewriteRule ^x9 https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # force http for

我有一个小问题,这是我用来强制https到签出目录的,只是一个预防措施,但问题是一旦你回到主页,它会将www插入URL

这是一个问题,因为视线的其余部分不使用www,有人能建议如何添加此选项以删除/保留www吗

# force https for all URLs in /checkout
RewriteCond %{HTTPS} =off
RewriteRule ^x9 https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# force http for all other URLs that are not in /checkout
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/x9
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

编辑

如果你说不是上面那部分。这个问题是在添加了上面的代码之后才开始的,我以前从来没有遇到过这个问题,下面的代码已经在我的网站上出现了好几个月了

 #Take off index.html
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule . http://www.%{HTTP_HOST}%1 [R=301,NE,L]

在这种情况下,保持.htaccess如下所示:

#Take off index.html
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule ^ http://%{HTTP_HOST}%1 [R=301,L]

# force https for all URLs in /checkout
RewriteCond %{HTTPS} =off
RewriteRule ^x9 https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# force http for all other URLs that are not in /checkout
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/x9
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

在这种情况下,保持.htaccess如下所示:

#Take off index.html
RewriteCond %{REQUEST_URI} ^(.*/)index\.html$ [NC]
RewriteRule ^ http://%{HTTP_HOST}%1 [R=301,L]

# force https for all URLs in /checkout
RewriteCond %{HTTPS} =off
RewriteRule ^x9 https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# force http for all other URLs that are not in /checkout
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/x9
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

此代码没有将
www
强制导入URL。您是否有其他.htaccess代码/框架强制执行此操作。@anubhava我已编辑了上述文章。谢谢。很明显,这个新代码在所有以
/index.html
结尾的URI中强制使用
www
。你想现在删除所有URL的www,包括http和https吗?@anubhava以前没有,这就是为什么我有点困惑的原因,但是的,我想从所有URL中删除www。这段代码并不是强迫
www
进入URL。您是否有其他.htaccess代码/框架强制执行此操作。@anubhava我已编辑了上述文章。谢谢。很明显,这个新代码在所有以
/index.html
结尾的URI中强制使用
www
。你想现在删除所有URL的www,包括http和https吗?@anubhava以前没有,这就是为什么我有点困惑,但是的,我想删除所有URL的www