【发布时间】:2017-06-03 00:34:34
【问题描述】:
我正在使用以下 .htaccess 代码执行以下操作:
- 将example.com重定向到https://example.com
- 将 wwww.example.com 重定向到https://example.com
- 将
/$1之后的所有内容重写为index.php?get=$1
.htaccess
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(?:www.)?(.*)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteRule ^([^.]+)/?$ index.php?get=$1 [L]
这很好用,但这段代码还能简化吗?
【问题讨论】: