2012-02-05 7 views
0

以下はhtaccessファイル全体です。それが必要(と管理フォルダを除いてすべてのために正常に動作します)htaccess rewriterule、合計8個のRewriteRulesは別々に動作しますが、すべてではありません。

  • WWWを追加します。入力されたURL(ただし、管理フォルダのための、ちょうどそれを残して)、
  • 入力されたURL(ただし、管理フォルダのための、ちょうどそれを残す)から非表示のindex.phpに、
  • は、httpをhttpsに置き換え、またはhttpsでHTTP入力されたURLに応じて、以下の.htaccessファイルで、both http:// (and https://) www.mydomain.com/administartion/index.phpは404エラーページに行き、

残念ながら(しかし、管理フォルダのため、管理フォルダは常にHTTPSをする必要がありませんので)。直し方?また

ので、#のBLOCK0、#のBLOCK1、.htaccessの仕事の罰金に#ブロック2が、彼らは自分の仕事を作る(管理フォルダへのURLが常にhttpsをしている、404ページにありませんリダイレクト)

、#のBLOCK0、#のBLOCK3 - #block8自分の仕事をしてください(管理フォルダ以外のURLでも問題ありません)

しかし、一度まとめたら(#block0-#block2の直後に#block3 - #block8を追加すると)、http://www.mydomain.com/administartion/index.phpが起動します404ページに行く。

何故修正するのですか? ありがとうございます。

#block0 
RewriteEngine On 

#block1 
#special rules for administration folder, http to https, if http 
RewriteCond %{REQUEST_URI} ^/administration 
RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [R,L=301] 

#block2 
RewriteCond %{REQUEST_URI} ^/administration 
RewriteRule ^administration - [NC,L] 
#URLs to administration folder should be stopped before this line. 




#block3 
RewriteCond %{HTTP_HOST} !^www.mydomain.com$ 
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L] 

#block4 
RewriteCond %{REQUEST_METHOD} !POST 
RewriteRule ^index.php/[L,R=301] 



#block5 
#if its a resource (add others that are missing) 
RewriteCond %{REQUEST_URI} \.(gif|css|png|js|jpe?g)$ [NC] 
#do nothing 
RewriteRule^- [L] 

#block6 
#determine if page is supposed to be http 
RewriteCond %{QUERY_STRING} (^|&)(p=home1?|qqq=home)(&|$) [NC,OR] 
#or if query string is empty 
RewriteCond %{QUERY_STRING} ^$ 
#set env var to 1 
RewriteRule^- [E=IS_HTTP:1] 

#block7 
#all pages that are supposed to be http redirected if https 
RewriteCond %{REQUEST_METHOD} !POST 
RewriteCond %{HTTPS} on 
RewriteCond %{ENV:IS_HTTP} 1 
RewriteRule^http://%{HTTP_HOST}%{REQUEST_URI} [R,L=301] 

#block8 
#all other pages are sent to https if not already so 
RewriteCond %{REQUEST_METHOD} !POST 
RewriteCond %{HTTPS} off 
RewriteCond %{ENV:IS_HTTP} !1 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [R,L=301] 

答えて

0

変更[R,L=301]https#block1#block7#block8

また、セットアップ証明書に[R=301,L]する必要があります、あなたは、Apacheのあなたの.confVirtualHost *:443を持っていますか?

+0

私はそれを変更しました。ありがとうございました。私の問題は解決していませんでしたが、問題を捕まえました。別の.htaccessファイルにありました(別の.htaccessファイルを削除して、別のフォルダにあります)。ありがとうございました。 – Haradzieniec

関連する問題