私の.htaccessファイルにルールを作成して、www.example.comと www.example.com/index.htmlをリダイレクトしたいとします。 comwwwとindex.htmlをwww以外のルートにリダイレクトする.htaccess
ありがとうございます。
私の.htaccessファイルにルールを作成して、www.example.comと www.example.com/index.htmlをリダイレクトしたいとします。 comwwwとindex.htmlをwww以外のルートにリダイレクトする.htaccess
ありがとうございます。
.htaccessファイルを作成します。そして、これを追加します。
#Force non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.YOURDOMAIN\.com [NC]
RewriteRule ^(.*)$ http://YOURDOMAIN.com/$1 [L,R=301]
www以外ではうまく動作しますが、www.example.com/index.htmlからexampleへのリダイレクトはまだありません。 com –
あなたはこのような単一のルールで両方の要件を組み合わせることができます。
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{THE_REQUEST} /index\.html[?\s] [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^(.*?)(?:index\.html)?$ http://%1/$1 [L,R=301,NE,NC]
をthiis以外に、[一般的なhtaccessのリダイレクトWWWのシームレス
RewriteCond %{HTTP_HOST} ^www\.sitename\.com [NC]
RewriteRule ^(.*)$ https://sitename.com/$1 [L,R=301,NC]
可能な複製を動作するはずです-www](http://stackoverflow.com/questions/234723/generic-htaccess-redirect-www-to-non-www) –
RewriteEngine On RewriteRule^index \ .html $/[R = 301、L] するRewriteRule ^(。*)/インデックス\ .htmlの$/$ 1/[R = 301、L] RewriteEngine でRewriteBase/ するRewriteCond%{HTTP_HOST} ^のWWW \(。*)$ [NC] のRewriteRuleに^(。*)$ http://%1/$ 1 [R = 301、L] –