LoginSignup
boarder
@boarder

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

クエリ文字列が入ったURLをリダイレクト

解決したいこと

先日xoopsからwordpressに移行したのですが301リダイレクトが出来なく困ってます。
通常のディレクトリは出来たのですが、クエリー文字列が含まれるURLが出来ません。

色々サイトを見て試してみたのですが、どうしてもうまくいきません。

具体的には
https://example.com/directory/index.php?content_id=15

https://example.com/access
に301リダイレクトしたいのですが
.htaccessにどのように書けばいいのでしょうか?

ご教示お願いします。

0

2Answer

ありがとうございます。

以下のようにしましたら、なんとか解決しました。
RewriteCond %{QUERY_STRING} (^|&)content_id=([^&]+)($|&)
RewriteRule .* - [E=X_QUERY_content_id:%2]
RewriteCond %{ENV:X_QUERY_content_id} ^15$
RewriteRule ^directory/index.php$ https://example.com/access? [R=301,L]

0Like

Your answer might help someone💌