0

CMS を変更したため、古い URL の一部をリダイレクトする必要があります。

私がやりたいことは次のとおりです。

  1. 「ブログ/アーカイブ」を削除
  2. アンダースコアをダッシュ​​に置き換えます
  3. 「.html」を末尾のスラッシュに置き換えます

古いリンク:

http://example.com/blog/archives/the_post_title.html

新しいリンク

http://example.com/the-post-title/

私は書きましたが、ある時点では機能していましたが、現在 500 エラーが発生しています。

RewriteRule ^([^_]*)_([^_]*_.*) $1-$2 [N]   #Replace "_" with "-" loop until one left
RewriteRule ^([^_]*)_([^_]*)$ /$1-$2        #Replace the last underscore
RewriteRule ^(.*?).html$ /$1/ [L,R=301]     #Strip the ".html" and use the filename as the url, note this as "permanently moved" (301)

サーバーエラーが発生する理由は何ですか?

4

1 に答える 1

0

これを次のように置き換えてみてください。

RewriteRule ^(.*)_(.*)$ /$1-$2
RewriteCond %{REQUEST_URI} !_
RewriteRule ^blog/archive/(.*).html$ /$1/ [L,R=301]
于 2012-06-15T06:45:54.527 に答える