【发布时间】:2016-12-21 19:07:57
【问题描述】:
这是我当前的 htaccess:
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^/1EE772B8EBDDECBA378B575830E7E1B3\.txt$
RewriteCond $1 !^(index\.php|assets|wmt|google1f91ad48697ced36\.html|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{HTTP_HOST} ^domain.com.br$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]
Options -Indexes
在第一个块行中,它将 http 重定向到 https; 在第二个块中,它允许直接访问并删除 index.php
如果 www 不存在,则在第三个块中添加 www。
最终目标是拥有如下网址:
https://www.domain.com.br欧 https://www.domain.com.br/foo/bar
问题是当用户输入地址时 Domain.com.br(没有 www 和 http,仅在站点的根目录中)它重定向到:
https://www.domain.com.br/index.php
只有在站点的根目录才会添加这个 index.php
有人知道我哪里出错了吗?
我也接受 htaccess 优化建议
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite