0

在我的 Wordpress 博客上,我曾经有一个不再需要的插件。该插件用于创建一堆如下所示的 URL:

http://tambnguyen.com/manage-subscriptions?srp=532&sra=s

postID 为 532。如何重定向查询字符串,以便将上述 URL 重定向到:

http://tambnguyen.com/?p=532

我尝试了一些方法但没有任何运气(“管理订阅”之后有一个可选的“/”

<IfModule mod_rewrite.c>
    RedirectMatch 301 ^/manage-subscriptions/?\?srp=(\d{1,5})(.*)$ http://tambnguyen.com/\?p=$1
</IfModule>

请帮忙。谢谢!

4

1 回答 1

1

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^srp=([^&]+) [NC]
RewriteRule ^manage-subscriptions/?$ /?p=%1 [L,R=301,NC]
于 2012-05-07T13:42:59.077 回答