1

最近、特定のリライトを機能させることについて質問しました。私はそのための実用的な答えを得て、私のサイトの1つでそれを使用しました。現在、このアプローチを再利用しようとしていますが、ロジックがWordpress Rewriteセクションにフォールスルーしており、自分のリダイレクトがまったくトリガーされていないことがわかりました。

# BEGIN Redirect deprecated site links to wp equivalent
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^news=13$
RewriteRule ^news_comments.php$ http://example.com/example-directory/ [R=301]
RewriteCond %{QUERY_STRING} ^news=51$
RewriteRule ^news_comments.php$ http://example.com/example-page.php [R=301]
</IfModule>
# END Redirect deprecated site links to wp equivalent

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

私は明らかにWordpressの書き直しが必要ですが、上部で指定したものがトリガーされ、Wordpressのルールをスキップする必要があります。

私は周りを検索して、次のようなものを使用するいくつかの提案を見ました...

...
RewriteCond %{QUERY_STRING} ^news=51$
RewriteRule ^news_comments.php$ http://example.com/example-page.php [R=301]
RewriteRule ^news_comments.php$ - [L]
</IfModule>

...しかし、私はそれを機能させることができないようです。何か案は?

4

1 に答える 1

1

リダイレクトの最後にフラグを追加する必要があり[L]ます。そうしないと、URIが残りのルールを通過し続け、リダイレクトが最後に発生します。その時までに、wordpressはすでにURIでその道を進んでいます。

RewriteCond %{QUERY_STRING} ^news=13$
RewriteRule ^news_comments.php$ http://example.com/example-directory/ [R=301,L]
RewriteCond %{QUERY_STRING} ^news=51$
RewriteRule ^news_comments.php$ http://example.com/example-page.php [R=301,L]
于 2012-08-02T02:14:56.913 に答える