htaccess,在站点根目录中添加index.php
这是我当前的访问权限:htaccess,在站点根目录中添加index.php,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,这是我当前的访问权限: 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|google1
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
最终目标是拥有如下URL:
ou
问题是当用户输入地址时
Domain.com.br(不带www和http,仅在站点根目录中)它重定向到:
index.php
它只在站点的根目录下添加index.php
有人知道我哪里出错了吗
我也接受htaccess优化建议您可以使用以下重构规则:
Options -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{REQUEST_URI} !^/1EE772B8EBDDECBA378B575830E7E1B3\.txt$
RewriteCond $0 !^(index\.php|assets|wmt|google1f91ad48697ced36\.html|robots\.txt) [NC]
RewriteRule .* index.php/$0 [L]
在完全清除浏览器缓存后进行测试。谢谢您的帮助。我测试了你的建议,apache返回500。有点不对劲:/啊!我打错了。现在修好了。你能再试一次吗?太好了!你是个天才:)