好的,所以我试图这样做:
http - > HTTPS 除了 / [A-f0-9] {11} /
https://www.domain.com/[a-f0-9] {11} / - > http://www.domain.com/[a-f0-9] {11} /
映射到控制器:index.php?(uri) 例如/ controller / action / id - >的index.php /控制器/动作/ ID
摘要:除了/ [a-f0-9] {11} /之外,所有网址都应该是https://www.domain.com/(。*),应该强制为http。
我有一套旧规则(见下文)看起来不太干净。 我已尝试添加它们以考虑/ [a-f0-9] {11}并最终重定向而不是重新映射,因此我最终得到www.domain.com/index.php/thepattern0
如何清理这些规则并使其有效?
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
#redirect to www
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
#redirect to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#hide index.php
RedirectMatch 404 .*php\.ini
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
答案 0 :(得分:1)
您可以使用:
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
#redirect to www
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#redirect to https
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !\s/+[a-f0-9]{11}[/?\s] [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
#redirect to http
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} \s/+[a-f0-9]{11}[/?\s] [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
#hide index.php
RewriteRule \.(?:php|ini)$ [L,R=404,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]