htaccess的帮助,需要强制WWW,HTTPS和删除的index.php [英] htaccess help, need to force www, https, and remove index.php
本文介绍了htaccess的帮助,需要强制WWW,HTTPS和删除的index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的htaccess文件重写从URL中移除的index.php
I have a rewrite in my htaccess file that removes index.php from the url
RewriteEngine on
RewriteCond $1 !^(images|media|system|themes|_css|_js|favicon\.ico|robots\.txt|cert\.html|index\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
除了这个,我要强制 WWW
和 HTTPS
提出任何要求,不具有任何
In addition to this, I want to force the www
and https
for any request that does not have either.
所以,最后所有的URL看起来应该是这样: https://www.example.com/whatever/something/
;和搜索引擎优化的目的,如果URL中肯綮,它应该301重定向到它的正确的版本,例如:
So ultimately all urls should look like this: https://www.example.com/whatever/something/
; and for SEO purposes, if a url misses the mark, it should 301 redirect to it's correct version, for example:
http://example.com/about/
301 redirect to
https://www.example.com/about/
很想一些帮助实现这个,谢谢!
Would love some help accomplishing that, thanks!
推荐答案
WWW力:
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L] # include 's' here to force ssl in addition to www
强制SSL:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
删除的index.php:
Remove "index.php":
RewriteCond %{THE_REQUEST} /index.php HTTP
RewriteRule (.*)index.php$ /$1 [R=301,L]
这篇关于htaccess的帮助,需要强制WWW,HTTPS和删除的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文