自分のドメインからユーザーをリダイレクトさせようとしています http://www.domain.com/blog
(かわいいURL)に http://www.domain.com/blog.html
他のページも同様です。 これまでのところ私は
RewriteEngine on
rewritecond %{http_host} domain.com/blog.html [nc]
rewriterule (.*)$ http://www.domain.com/blog$1 [r=301,nc]
.htaccess内何がおかしいのですか?誰かが私のためにそれを修正できますか?
前もって感謝します
回答:
回答№1は1あなたは「wwwからwwwへのリダイレクトとあなたがあなたの質問で尋ねたもの」を混ぜ合わせています。
これを試して:
Options -MultiViews
RewriteEngine on
# domain must have www
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^/?(.*)$ http://www.domain.com/$1 [R=301,L]
# forbid direct access to html pages
RewriteCond %{THE_REQUEST} ^.*/([A-Za-z-_]+).html [NC]
RewriteRule ^ /%1? [R=301,L]
# internal redirect from /page to page.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([A-Za-z-_]+)$ /$1.html [L]