特別な問題があります。http => httpsに行くすべてのリクエストを書き換える必要があります。また、wwwがない場合はURLを修正したいので、そのための書き換えルールもあります。
さて、書き直してはいけない例外が1つあります。リクエストがhttp://www.mydomain.com/api2 / ... /。の場合。
api2の下のすべてをhttpsに書き換えるべきではありません...
これが私の現在の.htaccessです:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [L]
# Start A2 Switcher Block
# Do not remove or modify this block! Added by PHP Switcher from cPanel to use an alterna$
<IfModule mod_suphp.c>
AddHandler application/x-httpd-php-5.4.13 .php
</IfModule>
# End A2 Switcher Block
誰か助けてもらえますか?
次のようなコードを作成します。
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule !^api2/ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
RewriteCond %{HTTPS} off
RewriteRule !^api2/ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
RewriteCond %{HTTPS} on
RewriteRule ^api2/ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^api2/ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NC]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [L]
# Start A2 Switcher Block
# Do not remove or modify this block! Added by PHP Switcher from cPanel to use an alterna$
<IfModule mod_suphp.c>
AddHandler application/x-httpd-php-5.4.13 .php
</IfModule>
# End A2 Switcher Block
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加