2016-12-10 6 views
1

現在、私の.htaccessはこのように見え、httpに最適です。 www.にリダイレクトされ、.htmlというファイル拡張子が削除されます。wwwをリダイレクトし、 ".html"拡張子を含むhtaccessのhttpsルール

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.html [NC,L] 

私は.htaccessのfrom this answerを試してみましたが、まだ問題のサイトは完全に台無しにされています。たとえば、https://example.com/workは404を示します。ソースコード内で/img/example-01.jpgにリンクされているすべての画像も表示されません。

RewriteCond %{HTTPS} off 
# First rewrite to HTTPS: 
# Don't put www. here. If it is already there it will be included, if not 
# the subsequent rule will catch it. 
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
# Now, rewrite any request to the wrong domain to use www. 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

あなたは.htaccessファイルの取得で私を助けてください:
1.
httpsにリダイレクト
2.
は、ファイルの拡張子から.htmlを削除しwww.サブドメインに
3.
をリダイレクトにその結果、example.com/workにはwork.htmlページが表示されます。

はあなたの助けをいただき、ありがとうございます。

答えて

0

あなたの現在の.htaccessが正常に動作している場合、この変更を行う必要があります。

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^www\. [OR] 
RewriteCond %{REQUEST_SCHEME} !https 
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.html [NC,L] 
+0

いやは、'https:'httpsと同じ404で//www.example.com/work'結果、:// WWWを.example.com/img/desktop/1.jpg 'と入力します。これはLet's Encrypt証明書です。すでにホストに連絡しています。このサイトは静的コンテンツを持つ超簡単です。 – lowtechsun

+0

.htaccesssを完全に削除すると、 'https:// www.example.com/img/desktop/1.jpg'が動作しますか? –

+0

ちょうどチェックし、いいえ、動作しません。正確に言うと、wwwへのリダイレクトはありません。削除された.htaccess URL'https://example.com/img/desktop/1.jpg 'は機能しません。 – lowtechsun

関連する問題