0

htaccess の書き換えに問題があり、ログインやニュース セクションなど、サイトのさまざまな部分を http ではなく https にリダイレクトする必要があります。正しい方法でこれを行う方法がわかりません。

だから現時点で私は

RewriteRule   ^login/?$  index.php?p=login [R,L]

これをhttpsにリダイレクトしたいのですが、次のことを試しましたが、うまくいかないようです

RewriteRule ^login/?$ https://%{SERVER_NAME}/index.php?p=login [R,L]

しかし、うまくいかないようです。私は何かを逃していますか?動作するように、他のすべての設定を書き直しました。私は何が欠けていますか?

また、httpsが設定されていないときに、htaccessに別のルールセットを使用させる方法はありますか?

アップデート:

だから私がやりたいことは、http://www.site.tld/login/https://www.site.tld/login/codeに書き換えてから、さらにhttps://www.site.tld/に書き換えることですindex.php?p=login . したがって、ユーザーにはhttps://www.site.tld/login/と表示されますが、実際にはhttps://www.site.tld/index.php?p=loginを実行しています

4

1 に答える 1

0
RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

特定のディレクトリ:

RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?secure/(.*) https://%{SERVER_NAME}/secure/$1 [R,L]
# This rule will redirect all users who are using any part of /secure/ to the same location but using HTTPS.
# i.e.  http://www.example.com/secure/ to https://www.example.com/secure/
# This means if you dont want to force HTTPS for all directories you can force it for a specific sub-section of the site.

詳細はこちら: http://wiki.apache.org/httpd/RewriteHTTPToHTTPS

于 2013-01-19T21:07:03.843 に答える