9

htaccessファイルを書き換えてURLからindex.phpを削除しました

RewriteEngine on
RewriteCond $1 !^(images|media|system|themes|_css|_js|favicon\.ico|robots\.txt|cert\.html|index\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

これに加えて、とを強制したいのですwwwhttps、どちらも持たないリクエストに対しては。

したがって、最終的にすべてのURLは次のようになりますhttps://www.example.com/whatever/something/。また、SEOの目的で、URLがマークを外した場合、次のように正しいバージョンにリダイレクトする必要があります。

http://example.com/about/
301 redirect to
https://www.example.com/about/

それを達成するための助けが欲しいです、ありがとう!

4

1 に答える 1

24

WWWを強制する:

RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L] # include 's' here to force ssl in addition to www

SSLを強制する:

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

「index.php」を削除します。

RewriteCond %{THE_REQUEST} /index.php HTTP
RewriteRule (.*)index.php$ /$1 [R=301,L]
于 2011-07-27T16:20:47.527 に答える